init commit

This commit is contained in:
flswld
2022-11-20 15:38:00 +08:00
parent eda2b643b9
commit 3efed3defe
5834 changed files with 636508 additions and 0 deletions

6
air/cmd/application.toml Normal file
View File

@@ -0,0 +1,6 @@
http_port = 8086
[logger]
level = "DEBUG"
method = "CONSOLE"
track_line = true

55
air/cmd/main.go Normal file
View File

@@ -0,0 +1,55 @@
package main
import (
"air/controller"
"air/service"
"flswld.com/common/config"
"flswld.com/logger"
"github.com/arl/statsviz"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
filePath := "./application.toml"
config.InitConfig(filePath)
logger.InitLogger()
logger.LOG.Info("air start")
go func() {
// 性能检测
err := statsviz.RegisterDefault()
if err != nil {
logger.LOG.Error("statsviz init error: %v", err)
}
err = http.ListenAndServe("0.0.0.0:1234", nil)
if err != nil {
logger.LOG.Error("perf debug http start error: %v", err)
}
}()
svc := service.NewService()
_ = controller.NewController(svc)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
logger.LOG.Info("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
logger.LOG.Info("air exit")
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
}
}