package main import ( "context" "flag" "log/slog" "os" "os/signal" "syscall" "gl/application/explorer" "gl/infrastructure/config" "gl/infrastructure/postgres" webadapter "gl/interface/web" ) func main() { configPath := flag.String("conf", "./dashboard.cfg.toml", "path to the dashboard TOML configuration file") flag.Parse() cfg, err := config.LoadDashboard(*configPath) if err != nil { slog.Error("load dashboard configuration", "error", err) os.Exit(1) } ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer stop() database, err := postgres.Open(ctx, cfg.Database) if err != nil { slog.Error("open GL database", "error", err) os.Exit(1) } defer database.Close() if err := database.Ping(ctx); err != nil { slog.Error("connect to GL database", "error", err) os.Exit(1) } repository := postgres.NewJournalRepository(database) handler := webadapter.NewHandler(explorer.NewService(repository)) serverConfig := webadapter.ServerConfig{ Host: cfg.HTTP.Host, Port: cfg.HTTP.Port, ReadHeaderTimeout: cfg.HTTP.ReadHeaderTimeout, ShutdownTimeout: cfg.HTTP.ShutdownTimeout, } slog.Info("starting GL explorer", "host", cfg.HTTP.Host, "port", cfg.HTTP.Port) if err := webadapter.Run(ctx, serverConfig, handler); err != nil { slog.Error("GL explorer stopped", "error", err) os.Exit(1) } }