-
Notifications
You must be signed in to change notification settings - Fork 97
/
app.go
64 lines (53 loc) · 1.67 KB
/
app.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package hydra
import (
"github.com/lib4dev/cli"
"github.com/micro-plat/hydra/global"
"github.com/micro-plat/hydra/global/compatible"
"github.com/micro-plat/hydra/services"
"github.com/micro-plat/lib4go/logger"
_ "github.com/micro-plat/hydra/registry/watcher/wchild"
_ "github.com/micro-plat/hydra/registry/watcher/wvalue"
_ "github.com/micro-plat/hydra/hydra/cmds/conf"
_ "github.com/micro-plat/hydra/hydra/cmds/install"
_ "github.com/micro-plat/hydra/hydra/cmds/remove"
_ "github.com/micro-plat/hydra/hydra/cmds/run"
_ "github.com/micro-plat/hydra/hydra/cmds/update"
_ "github.com/micro-plat/hydra/hydra/cmds/start"
_ "github.com/micro-plat/hydra/hydra/cmds/status"
_ "github.com/micro-plat/hydra/hydra/cmds/stop"
_ "github.com/micro-plat/hydra/hydra/cmds/restart"
_ "github.com/micro-plat/hydra/registry/registry/dbr"
_ "github.com/micro-plat/hydra/registry/registry/filesystem"
_ "github.com/micro-plat/hydra/registry/registry/localmemory"
_ "github.com/micro-plat/hydra/registry/registry/redis"
_ "github.com/micro-plat/hydra/registry/registry/zookeeper"
)
//MicroApp 微服务应用
type MicroApp struct {
app *cli.App
services.IService
}
//NewApp 创建微服务应用
func NewApp(opts ...Option) (m *MicroApp) {
m = &MicroApp{
IService: services.Def,
}
for _, opt := range opts {
opt()
}
return m
}
//Start 启动服务器
func (m *MicroApp) Start() {
defer logger.Close()
m.app = cli.New(cli.WithVersion(global.Version), cli.WithUsage(global.Usage))
m.app.Start()
}
//Close 关闭服务器
func (m *MicroApp) Close() {
Close()
}
//Close 关闭服务器
func Close() {
compatible.AppClose()
}