58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"git.ostiwe.com/ostiwe-com/status/migration"
|
|
appLog "git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
"git.ostiwe.com/ostiwe-com/status/pkg/args"
|
|
"git.ostiwe.com/ostiwe-com/status/server"
|
|
_ "git.ostiwe.com/ostiwe-com/status/settings"
|
|
"github.com/alexflint/go-arg"
|
|
)
|
|
|
|
var appArgs args.AppArgs
|
|
|
|
func main() {
|
|
arg.MustParse(&appArgs)
|
|
|
|
if appArgs.Migration != nil && appArgs.Migration.Create != nil {
|
|
if err := migration.CreateMigration(appArgs.Migration.Create.Name); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
if appArgs.Server != nil {
|
|
migration.RunMigration()
|
|
|
|
server.Run(appArgs.Server)
|
|
return
|
|
}
|
|
|
|
// TODO: Rewrite to use gin router, instead of chi router
|
|
// 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")
|
|
}
|