package main import ( "context" "errors" "log" "net/http" "os" "os/signal" "syscall" "time" "git.scity.us/TAI/TA-Deployment-Broker/internal/app" ) func main() { cfg, err := app.LoadConfig() if err != nil { log.Fatalf("configuration: %v", err) } server, err := app.New(cfg) if err != nil { log.Fatalf("initialize: %v", err) } defer server.Close() httpServer := &http.Server{ Addr: cfg.ListenAddr, Handler: server.Routes(), ReadHeaderTimeout: 10 * time.Second, ReadTimeout: 30 * time.Minute, WriteTimeout: 30 * time.Minute, IdleTimeout: 90 * time.Second, MaxHeaderBytes: 1 << 20, } go func() { log.Printf("TAPM Deployment Access listening on %s", cfg.ListenAddr) if err := httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { log.Fatalf("serve: %v", err) } }() stop := make(chan os.Signal, 1) signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM) <-stop ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() if err := httpServer.Shutdown(ctx); err != nil { log.Printf("shutdown: %v", err) } }