package main import ( "fmt" "net/http" appLog "git.ostiwe.com/ostiwe-com/status/modules/log" "git.ostiwe.com/ostiwe-com/status/pkg/args" "git.ostiwe.com/ostiwe-com/status/router" "git.ostiwe.com/ostiwe-com/status/server" _ "git.ostiwe.com/ostiwe-com/status/settings" "github.com/alexflint/go-arg" "github.com/go-chi/chi/v5" ) var appArgs args.AppArgs func main() { arg.MustParse(&appArgs) if appArgs.Server != nil { server.Run(appArgs.Server) return } if appArgs.ServerDocumentation != nil { appLog.Global.Get(appLog.SYSTEM).Info("Collect documentation") docs := router.Documentate() if !appArgs.ServerDocumentation.Plain { chiRouter := chi.NewRouter() err := docs.SetupRoutes(chiRouter, docs) if err != nil { appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Setup docs routes error: %v", err)) return } appLog.Global.Get(appLog.SYSTEM).Info(fmt.Sprintf("Start documentation server on port: %s", appArgs.ServerDocumentation.Port)) err = http.ListenAndServe(fmt.Sprintf(":%s", appArgs.ServerDocumentation.Port), chiRouter) if err != nil { appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Startup server error: %v", err)) } return } } appLog.Global.Get(appLog.SYSTEM).Info("Exit from application") }