main.go 976 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "github.com/0xJacky/Nginx-UI/logger"
  6. "github.com/0xJacky/Nginx-UI/server"
  7. "github.com/0xJacky/Nginx-UI/server/service"
  8. "github.com/0xJacky/Nginx-UI/server/settings"
  9. "github.com/gin-gonic/gin"
  10. "github.com/jpillora/overseer"
  11. "github.com/jpillora/overseer/fetcher"
  12. )
  13. func main() {
  14. var confPath string
  15. flag.StringVar(&confPath, "config", "app.ini", "Specify the configuration file")
  16. flag.Parse()
  17. settings.Init(confPath)
  18. logger.Init(settings.ServerSettings.RunMode)
  19. gin.SetMode(settings.ServerSettings.RunMode)
  20. defer logger.Sync()
  21. r, err := service.GetRuntimeInfo()
  22. if err != nil {
  23. logger.Fatal(err)
  24. }
  25. overseer.Run(overseer.Config{
  26. Program: server.Program,
  27. Address: fmt.Sprintf(":%s", settings.ServerSettings.HttpPort),
  28. Fetcher: &fetcher.File{Path: r.ExPath},
  29. TerminateTimeout: 0,
  30. })
  31. }