-
Notifications
You must be signed in to change notification settings - Fork 20
/
main.go
62 lines (57 loc) · 1.62 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"github.com/goal-web/application"
"github.com/goal-web/auth"
"github.com/goal-web/bloomfilter"
"github.com/goal-web/cache"
"github.com/goal-web/config"
"github.com/goal-web/contracts"
"github.com/goal-web/database"
"github.com/goal-web/email"
"github.com/goal-web/encryption"
"github.com/goal-web/events"
"github.com/goal-web/filesystem"
"github.com/goal-web/goal/app/console"
"github.com/goal-web/goal/app/exceptions"
"github.com/goal-web/goal/app/providers"
config2 "github.com/goal-web/goal/config"
"github.com/goal-web/hashing"
"github.com/goal-web/queue"
"github.com/goal-web/ratelimiter"
"github.com/goal-web/redis"
"github.com/goal-web/serialization"
"github.com/goal-web/supports/logs"
)
func main() {
env := config.NewToml(config.File("env.toml"))
app := application.Singleton(env.GetBool("app.debug"))
// 设置异常处理器
app.Singleton("exceptions.handler", func() contracts.ExceptionHandler {
return exceptions.NewHandler()
})
app.RegisterServices(
config.NewService(env, config2.GetConfigProviders()),
events.NewService(),
providers.NewEvents(),
hashing.NewService(),
encryption.NewService(),
filesystem.NewService(),
serialization.NewService(),
redis.NewService(),
cache.NewService(),
bloomfilter.NewService(),
auth.NewService(),
ratelimiter.NewService(),
console.NewService(),
database.NewService(),
queue.NewService(false),
email.NewService(),
providers.NewApp(),
providers.NewMicro(true),
)
if errors := app.Start(); len(errors) > 0 {
logs.WithField("errors", errors).Fatal("goal 异常!")
} else {
logs.Default().Info("goal 已关闭")
}
}