Files
rogueking 0bae08f39c
Some checks failed
golangci-lint / lint (push) Failing after 25s
build / Build (push) Successful in 32s
Run Go Tests / build (push) Failing after 0s
Build and Push Docker Image / Build and push image (push) Successful in 2m33s
roboflow working, and added integration tests
2025-05-06 20:43:57 -07:00

47 lines
1.0 KiB
Go

package main
import (
"context"
"os"
"os/signal"
"syscall"
"time"
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/config"
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/logger"
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/router"
)
func main() {
flags := config.DeclareFlags()
port := config.ConfigPort(flags)
// Set up routes
router := router.SetupRouter(config.AllowedOrigins)
server := config.SetupServer(port, router, flags)
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
go func() {
logger.Info("Starting server on %s", port)
err := server.ListenAndServe()
if err != nil {
logger.Error("Error starting server %v", err)
}
}()
<-stop
logger.Info("Shutting down gracefully...")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Error("Error shutting down HTTP server: %v", err)
}
logger.Info("Shutdown complete.")
}