sonarqube-badges/main.go

42 lines
887 B
Go
Raw Permalink Normal View History

2025-03-13 08:25:39 +01:00
package main
import (
"context"
2025-03-15 01:49:52 +01:00
"github.com/joho/godotenv"
"os"
"os/signal"
2025-03-13 08:25:39 +01:00
"sonarqube-badge/config"
"sonarqube-badge/router"
"sonarqube-badge/store"
2025-03-15 01:49:52 +01:00
"syscall"
2025-03-13 08:25:39 +01:00
)
func main() {
2025-03-15 01:49:52 +01:00
_ = godotenv.Load(".env")
if os.Getenv("DATA_PATH") == "" || os.Getenv("SECRET") == "" || os.Getenv("SQ_HOST") == "" {
println("Environment variables missing")
println("Please ensure that the following environment variables are set: ")
println("- DATA_PATH")
println("- SECRET")
println("- SQ_HOST")
os.Exit(1)
}
2025-03-13 08:25:39 +01:00
ctx := context.Background()
ctx = config.ProcessConfiguration(ctx)
ctx = store.CreateDatabase(ctx)
2025-03-15 01:49:52 +01:00
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
signal.Notify(c, os.Interrupt, syscall.SIGQUIT)
signal.Notify(c, os.Interrupt, syscall.SIGKILL)
go func() {
<-c
println("Stopping server")
os.Exit(1)
}()
2025-03-13 08:25:39 +01:00
router.StartServer(ctx)
}