Cloudreve/main.go

41 lines
836 B
Go
Raw Normal View History

2019-11-04 20:30:12 +08:00
package main
2019-11-05 12:31:22 +08:00
import (
2019-11-16 16:11:37 +08:00
"github.com/HFO4/cloudreve/models"
2020-02-04 15:29:52 +08:00
"github.com/HFO4/cloudreve/pkg/aria2"
2019-12-10 11:13:33 +08:00
"github.com/HFO4/cloudreve/pkg/auth"
2019-12-08 22:17:36 +08:00
"github.com/HFO4/cloudreve/pkg/authn"
"github.com/HFO4/cloudreve/pkg/cache"
2019-11-16 16:11:37 +08:00
"github.com/HFO4/cloudreve/pkg/conf"
2020-02-15 14:02:21 +08:00
"github.com/HFO4/cloudreve/pkg/crontab"
"github.com/HFO4/cloudreve/pkg/email"
2020-02-02 14:40:07 +08:00
"github.com/HFO4/cloudreve/pkg/task"
2019-11-16 16:11:37 +08:00
"github.com/HFO4/cloudreve/routers"
"github.com/gin-gonic/gin"
2019-11-05 12:31:22 +08:00
)
2019-11-04 20:30:12 +08:00
2019-11-07 15:56:05 +08:00
func init() {
2019-11-09 18:06:29 +08:00
conf.Init("conf/conf.ini")
// Debug 关闭时,切换为生产模式
if !conf.SystemConfig.Debug {
gin.SetMode(gin.ReleaseMode)
}
cache.Init()
if conf.SystemConfig.Mode == "master" {
model.Init()
authn.Init()
2020-02-02 14:40:07 +08:00
task.Init()
2020-02-04 15:29:52 +08:00
aria2.Init()
2020-02-15 14:02:21 +08:00
email.Init()
crontab.Init()
}
2019-12-10 11:13:33 +08:00
auth.Init()
2019-11-07 15:56:05 +08:00
}
2019-11-04 20:30:12 +08:00
func main() {
2019-11-05 12:31:22 +08:00
api := routers.InitRouter()
api.Run(conf.SystemConfig.Listen)
2019-11-05 12:31:22 +08:00
2019-11-04 20:30:12 +08:00
}