2023-04-06 13:46:19 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"film/config"
|
2024-04-27 23:12:44 +08:00
|
|
|
"film/global"
|
2023-04-06 13:46:19 +08:00
|
|
|
"film/worker"
|
2024-04-27 23:12:44 +08:00
|
|
|
"film/worker/nowcar"
|
2023-04-06 13:46:19 +08:00
|
|
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
|
|
|
"github.com/rifflock/lfshook"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/smbrave/goutil"
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initLog() {
|
|
|
|
cfg := config.GetConfig()
|
|
|
|
logfile := "log/server.log"
|
|
|
|
writer, err := rotatelogs.New(
|
|
|
|
logfile+".%Y%m%d",
|
|
|
|
rotatelogs.WithLinkName(logfile),
|
|
|
|
rotatelogs.WithMaxAge(time.Duration(86400*7)*time.Second),
|
|
|
|
rotatelogs.WithRotationTime(time.Duration(86400)*time.Second),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pathMap := lfshook.WriterMap{
|
|
|
|
log.TraceLevel: writer,
|
|
|
|
log.DebugLevel: writer,
|
|
|
|
log.InfoLevel: writer,
|
|
|
|
log.WarnLevel: writer,
|
|
|
|
log.ErrorLevel: writer,
|
|
|
|
log.FatalLevel: writer,
|
|
|
|
log.PanicLevel: writer,
|
|
|
|
}
|
|
|
|
|
|
|
|
log.AddHook(lfshook.NewHook(pathMap, new(goutil.LogFile)))
|
|
|
|
|
|
|
|
log.SetOutput(os.Stdout)
|
|
|
|
log.SetReportCaller(true)
|
|
|
|
log.SetFormatter(new(goutil.LogFile))
|
|
|
|
log.SetLevel(log.Level(cfg.Server.LogLevel))
|
|
|
|
}
|
2023-04-06 13:54:59 +08:00
|
|
|
|
2024-04-27 23:43:21 +08:00
|
|
|
func main() {
|
2023-04-06 13:46:19 +08:00
|
|
|
config.LoadServerConfig()
|
2023-04-09 11:38:19 +08:00
|
|
|
config.LoadDadiConfig()
|
2023-04-09 13:01:04 +08:00
|
|
|
config.LoadHahaConfig()
|
2023-04-06 13:46:19 +08:00
|
|
|
initLog()
|
2024-04-27 23:12:44 +08:00
|
|
|
|
|
|
|
global.InitDB()
|
2023-04-06 13:46:19 +08:00
|
|
|
|
2023-04-09 02:11:58 +08:00
|
|
|
work := &worker.Worker{}
|
|
|
|
work.Run()
|
2023-04-06 13:46:19 +08:00
|
|
|
}
|
2024-04-27 23:12:44 +08:00
|
|
|
|
2024-04-27 23:43:21 +08:00
|
|
|
func main2() {
|
2024-04-27 23:12:44 +08:00
|
|
|
config.LoadServerConfig()
|
|
|
|
config.LoadDadiConfig()
|
|
|
|
config.LoadHahaConfig()
|
|
|
|
initLog()
|
|
|
|
|
|
|
|
global.InitDB()
|
|
|
|
nowcar.Sync()
|
|
|
|
}
|