-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (44 loc) · 1.76 KB
/
main.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
// Copyright 2021 jianfengye. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"github.com/choi006/bbsgo/app/console"
"github.com/choi006/bbsgo/app/http"
"github.com/gohade/hade/framework"
"github.com/gohade/hade/framework/provider/app"
"github.com/gohade/hade/framework/provider/cache"
"github.com/gohade/hade/framework/provider/config"
"github.com/gohade/hade/framework/provider/distributed"
"github.com/gohade/hade/framework/provider/env"
"github.com/gohade/hade/framework/provider/id"
"github.com/gohade/hade/framework/provider/kernel"
"github.com/gohade/hade/framework/provider/log"
"github.com/gohade/hade/framework/provider/orm"
"github.com/gohade/hade/framework/provider/redis"
"github.com/gohade/hade/framework/provider/ssh"
"github.com/gohade/hade/framework/provider/trace"
)
func main() {
// 初始化服务容器
container := framework.NewHadeContainer()
// 绑定App服务提供者
container.Bind(&app.HadeAppProvider{})
// 后续初始化需要绑定的服务提供者...
container.Bind(&env.HadeEnvProvider{})
container.Bind(&distributed.LocalDistributedProvider{})
container.Bind(&config.HadeConfigProvider{})
container.Bind(&id.HadeIDProvider{})
container.Bind(&trace.HadeTraceProvider{})
container.Bind(&log.HadeLogServiceProvider{})
container.Bind(&orm.GormProvider{})
container.Bind(&redis.RedisProvider{})
container.Bind(&cache.HadeCacheProvider{})
container.Bind(&ssh.SSHProvider{})
// 将HTTP引擎初始化,并且作为服务提供者绑定到服务容器中
if engine, err := http.NewHttpEngine(container); err == nil {
container.Bind(&kernel.HadeKernelProvider{HttpEngine: engine})
}
// 运行root命令
console.RunCommand(container)
}