main.go
@@ -2,8 +2,11 @@ import ( "car-service/controllers" "car-service/models" _ "car-service/routers" "car-service/service" "github.com/astaxie/beego" "github.com/robfig/cron" ) func main() { @@ -11,6 +14,13 @@ beego.BConfig.WebConfig.DirectoryIndex = true beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" } controllers.Schedule() models.InitDb() go controllers.ComputeSpaceLeftRealTime() //每天同步海康数据,看人员id是否有发生变化 c := cron.New() c.AddFunc("@daily", func() { service.SyncHikPerson() }) c.Start() beego.Run() }