package main import ( "context" "fmt" "os" "os/signal" "website/internal/log" "website/internal/server" "github.com/ardanlabs/conf/v3" "github.com/pkg/errors" ) func main() { runtimeConfig := server.Config{} help, err := conf.Parse("", &runtimeConfig) if err != nil { if errors.Is(err, conf.ErrHelpWanted) { fmt.Println(help) os.Exit(1) } panic("parsing runtime configuration" + err.Error()) } log.Configure(!runtimeConfig.Development) sv, err := server.New(&runtimeConfig) if err != nil { log.Error("could not create server", "error", err) return } ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() go func() { err = sv.Start() if err != nil { // Error starting or closing listener: log.Fatal("error %v", err) } }() <-ctx.Done() log.Debug("calling stop") sv.Stop() log.Debug("done") }