-
Notifications
You must be signed in to change notification settings - Fork 1
/
goframe.go
40 lines (32 loc) · 947 Bytes
/
goframe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package goframe
import (
"flag"
"github.com/realjf/goframe/internal/server"
)
var (
// flag启动参数
ConfigPath string
CaCertPath string
CaKeyPath string
DefaultServer *server.Server
)
func init() {
// 启动参数处理
// 配置文件路径
flag.StringVar(&ConfigPath, "config-path", "config/config.yaml", "--config-path, specify config file path;default path is config/conf.toml")
flag.StringVar(&CaCertPath, "ca-cert", "config/ca.cer", "--ca-cert, specify ca-cert file path;default path is config/ca.cer")
flag.StringVar(&CaKeyPath, "ca-key", "config/ca.key", "--ca-key, specify ca-key file path;default path is config/ca.key")
flag.Parse()
}
func NewServer(configPath string) *server.Server {
return &server.Server{
ConfigPath: configPath,
}
}
func NewDefaultServer() *server.Server {
if DefaultServer != nil {
return DefaultServer
}
DefaultServer = NewServer("./config/config.yaml")
return DefaultServer
}