2022-11-16 10:20:07 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-02-03 04:43:37 +00:00
|
|
|
"flag"
|
2022-11-20 14:11:47 +00:00
|
|
|
nested "github.com/Lyrics-you/sail-logrus-formatter/sailor"
|
2022-11-16 10:20:07 +00:00
|
|
|
"github.com/huoxue1/qinglong-go/controller"
|
2022-11-26 02:31:26 +00:00
|
|
|
"github.com/huoxue1/qinglong-go/service"
|
2023-01-13 11:32:50 +00:00
|
|
|
"github.com/huoxue1/qinglong-go/service/config"
|
2023-02-18 07:22:05 +00:00
|
|
|
env_check "github.com/huoxue1/qinglong-go/utils/env-check"
|
2022-11-20 14:11:47 +00:00
|
|
|
rotates "github.com/lestrrat-go/file-rotatelogs"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"time"
|
2022-11-16 10:20:07 +00:00
|
|
|
)
|
|
|
|
|
2023-02-03 04:43:37 +00:00
|
|
|
var (
|
|
|
|
address string
|
|
|
|
)
|
|
|
|
|
2022-11-20 14:11:47 +00:00
|
|
|
func init() {
|
2022-11-26 02:31:26 +00:00
|
|
|
w, err := rotates.New(path.Join("data", "log", "qinglong-go", "%Y-%m-%d.log"), rotates.WithRotationTime(time.Hour*24))
|
2022-11-20 14:11:47 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("rotates init err: %v", err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
log.SetOutput(io.MultiWriter(w, os.Stdout))
|
|
|
|
log.SetFormatter(&nested.Formatter{
|
|
|
|
FieldsOrder: nil,
|
|
|
|
TimeStampFormat: "2006-01-02 15:04:05",
|
|
|
|
CharStampFormat: "",
|
|
|
|
HideKeys: false,
|
|
|
|
Position: true,
|
|
|
|
Colors: true,
|
|
|
|
FieldsColors: true,
|
|
|
|
FieldsSpace: true,
|
|
|
|
ShowFullLevel: false,
|
|
|
|
LowerCaseLevel: true,
|
|
|
|
TrimMessages: true,
|
|
|
|
CallerFirst: false,
|
|
|
|
CustomCallerFormatter: nil,
|
|
|
|
})
|
2023-02-03 04:43:37 +00:00
|
|
|
flag.StringVar(&address, "add", "0.0.0.0:5700", "the ql listen address!")
|
|
|
|
flag.Parse()
|
|
|
|
config.SetAddress(address)
|
2022-11-20 14:11:47 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 10:20:07 +00:00
|
|
|
func main() {
|
2023-02-18 07:22:05 +00:00
|
|
|
env_check.CheckStatic()
|
2022-11-26 02:31:26 +00:00
|
|
|
service.AppInit()
|
2022-11-16 10:20:07 +00:00
|
|
|
engine := controller.Router()
|
2023-02-03 04:43:37 +00:00
|
|
|
_ = engine.Run(address)
|
2022-11-16 10:20:07 +00:00
|
|
|
}
|