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