-
Notifications
You must be signed in to change notification settings - Fork 61
/
main.go
executable file
·43 lines (35 loc) · 1.08 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
// Copyright (c) 2019,CAOHONGJU 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 (
"context"
"github.com/cnotch/ipchub/config"
"github.com/cnotch/ipchub/provider/auth"
"github.com/cnotch/ipchub/provider/route"
"github.com/cnotch/ipchub/service"
"github.com/cnotch/scheduler"
"github.com/cnotch/xlog"
)
func main() {
// 初始化配置
config.InitConfig()
// 初始化全局计划任务
scheduler.SetPanicHandler(func(job *scheduler.ManagedJob, r interface{}) {
xlog.Errorf("scheduler task panic. tag: %v, recover: %v", job.Tag, r)
})
// 初始化各类提供者
// 路由表提供者
routetableProvider := config.LoadRoutetableProvider(route.JSON)
route.Reset(routetableProvider.(route.Provider))
// 用户提供者
userProvider := config.LoadUsersProvider(auth.JSON)
auth.Reset(userProvider.(auth.UserProvider))
// Start new service
svc, err := service.NewService(context.Background(), xlog.L())
if err != nil {
xlog.L().Panic(err.Error())
}
// Listen and serve
svc.Listen()
}