mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
chore: prepare v2.0.0-beta.37
This commit is contained in:
parent
6dc6092bfc
commit
c8c0446308
15 changed files with 75 additions and 54 deletions
44
main.go
44
main.go
|
@ -3,34 +3,57 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/0xJacky/Nginx-UI/internal/kernal"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/internal/kernel"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/router"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jpillora/overseer"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/uozi-tech/cosy"
|
||||
cKernel "github.com/uozi-tech/cosy/kernel"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
cRouter "github.com/uozi-tech/cosy/router"
|
||||
cSettings "github.com/uozi-tech/cosy/settings"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Program(confPath string) func(state overseer.State) {
|
||||
return func(state overseer.State) {
|
||||
defer logger.Sync()
|
||||
|
||||
defer logger.Info("Server exited")
|
||||
cosy.RegisterModels(model.GenerateAllModel()...)
|
||||
|
||||
cosy.RegisterAsyncFunc(kernal.Boot, router.InitRouter)
|
||||
cosy.RegisterAsyncFunc(kernel.Boot, router.InitRouter)
|
||||
|
||||
if state.Listener != nil {
|
||||
cosy.SetListener(state.Listener)
|
||||
// Initialize settings package
|
||||
settings.Init(confPath)
|
||||
|
||||
cosy.Boot(confPath)
|
||||
// Set gin mode
|
||||
gin.SetMode(cSettings.ServerSettings.RunMode)
|
||||
|
||||
logger.Infof("Nginx configuration directory: %s", nginx.GetConfPath())
|
||||
// Initialize logger package
|
||||
logger.Init(cSettings.ServerSettings.RunMode)
|
||||
defer logger.Sync()
|
||||
|
||||
if state.Listener == nil {
|
||||
return
|
||||
}
|
||||
// Gin router initialization
|
||||
cRouter.Init()
|
||||
|
||||
// Kernel boot
|
||||
cKernel.Boot()
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", cSettings.ServerSettings.Host, cSettings.ServerSettings.Port)
|
||||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: cRouter.GetEngine(),
|
||||
}
|
||||
if err := srv.Serve(state.Listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
logger.Fatalf("listen: %s\n", err)
|
||||
}
|
||||
logger.Info("Server exited")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +62,7 @@ func main() {
|
|||
flag.StringVar(&confPath, "config", "app.ini", "Specify the configuration file")
|
||||
flag.Parse()
|
||||
|
||||
settings.Migrate(confPath)
|
||||
cSettings.Init(confPath)
|
||||
settings.Init(confPath)
|
||||
|
||||
overseer.Run(overseer.Config{
|
||||
Program: Program(confPath),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue