-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
executable file
·40 lines (37 loc) · 981 Bytes
/
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
package main
import (
"github.com/iguidao/redis-manager/src/cfg"
"github.com/iguidao/redis-manager/src/middleware/casbin"
"github.com/iguidao/redis-manager/src/middleware/logger"
"github.com/iguidao/redis-manager/src/middleware/model"
"github.com/iguidao/redis-manager/src/middleware/mysql"
"github.com/iguidao/redis-manager/src/middleware/rcron"
"github.com/iguidao/redis-manager/src/rhttp"
"github.com/robfig/cron"
)
func init() {
if err := cfg.Init(""); err != nil {
panic(err)
}
logger.SetupLogger()
mysql.Connect(cfg.Get_Info_String("MYSQL"))
mysql.Migrate()
casbin.Connect()
}
func main() {
c := cron.New()
var calendarcrontime string
calendarcrontime = mysql.DB.GetOneCfgValue(model.CLOUDREFRESH)
if calendarcrontime == "" {
calendarcrontime = "@every 10m"
}
c.AddFunc(calendarcrontime, func() {
rcron.CloudRefresh()
})
c.Start()
listen := cfg.Get_Info_String("addr")
if listen == "" {
listen = ":8000"
}
rhttp.NewServer().Run(listen)
}