nginx-proxy-manager/backend/cmd/server/main.go
2022-07-15 08:52:38 +10:00

55 lines
1.0 KiB
Go

package main
import (
"os"
"os/signal"
"syscall"
"npm/internal/api"
"npm/internal/config"
"npm/internal/database"
"npm/internal/entity/certificate"
"npm/internal/entity/host"
"npm/internal/entity/setting"
"npm/internal/jobqueue"
"npm/internal/logger"
)
var commit string
var version string
var sentryDSN string
func main() {
config.InitArgs(&version, &commit)
config.Init(&version, &commit, &sentryDSN)
database.Migrate(func() {
setting.ApplySettings()
database.CheckSetup()
// Internal Job Queue
jobqueue.Start()
certificate.AddPendingJobs()
host.AddPendingJobs()
// Http server
api.StartServer()
irqchan := make(chan os.Signal, 1)
signal.Notify(irqchan, syscall.SIGINT, syscall.SIGTERM)
for irq := range irqchan {
if irq == syscall.SIGINT || irq == syscall.SIGTERM {
logger.Info("Got ", irq, " shutting server down ...")
// Close db
err := database.GetInstance().Close()
if err != nil {
logger.Error("DatabaseCloseError", err)
}
// nolint
jobqueue.Shutdown()
break
}
}
})
}