aboutsummaryrefslogtreecommitdiff
path: root/web/cli.go
blob: f925a9510be1ce1acb9a7be335a49465746104c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

package web

import (
	"database/sql"
	"log/slog"

	"github.com/martinlehoux/biking_home/config"
	"github.com/martinlehoux/kagamigo/kcore"
)

func ServeCmd(db *sql.DB, configPath string, appConfig config.Config, enablePprof bool) {
	server := NewServer(db, configPath).WithPprof(enablePprof)
	if enablePprof {
		slog.Info("pprof enabled", "endpoint", appConfig.Server.PublicURL+"/debug/pprof/")
	}
	slog.Info("Starting web server", "address", appConfig.Server.PublicURL)
	kcore.Expect(server.ListenAndServe(appConfig.Server.Address), "web server stopped")
}