41 lines
887 B
Go
41 lines
887 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"github.com/joho/godotenv"
|
|
"os"
|
|
"os/signal"
|
|
"sonarqube-badge/config"
|
|
"sonarqube-badge/router"
|
|
"sonarqube-badge/store"
|
|
"syscall"
|
|
)
|
|
|
|
func main() {
|
|
_ = 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)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
ctx = config.ProcessConfiguration(ctx)
|
|
ctx = store.CreateDatabase(ctx)
|
|
|
|
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)
|
|
}()
|
|
|
|
router.StartServer(ctx)
|
|
}
|