-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (36 loc) · 1.17 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
package main
import (
"context"
"fmt"
"github.com/cihub/seelog"
"github.com/didi/tg-example/controller"
"github.com/didi/tg-example/logic/cron"
"github.com/didi/tg-example/logic/dispatcher"
"github.com/didi/tg-flow/common/tlog"
"github.com/gin-gonic/gin"
"log"
)
func main(){
// 初始化seelog
seeLog, err := seelog.LoggerFromConfigAsFile("conf/tlog.xml")
if err != nil {
log.Fatalf("Error initializing seelog: %v", err)
}
// 为tg-flow提供CountLogger初始化参数
tlog.InitCountLoggerFromSeelog(seeLog, nil)
defer seeLog.Flush()
//如有redis访问的需要(如采用从redis加载工作流配置的方式),可在此处初始化,对应的redis配置文件为:conf/app.conf
//redis.InitRedisHandlers([]string{"redis"})
//工作流引擎初始化
dispatcher.InitWorkflowEngine(context.TODO())
//定时任务
cron.StartCronTask()
r := gin.New()
es := &controller.ExampleService{}
r.GET("/api/recommend", es.Recommend)
tlog.Handler.Info("tg-example server start finished !!!")
// 运行应用,监听在端口8080
if err := r.Run(":8080"); err != nil {
tlog.Handler.Errorf(context.TODO(), "interface_query", fmt.Sprintf("Error starting server: %v", err))
}
}