logs
This commit is contained in:
parent
1d4c32c360
commit
3d657f6951
|
@ -20,8 +20,9 @@ var (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
||||||
|
logger.Info("starting server", "port", *port, "dbPath", *dbPath)
|
||||||
|
|
||||||
repo, err := app.NewSQLite(*dbPath)
|
repo, err := app.NewSQLite(*dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("could not create new sqlite repo: %s", err.Error())
|
fmt.Printf("could not create new sqlite repo: %s", err.Error())
|
||||||
|
@ -33,8 +34,11 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
go http.ListenAndServe(fmt.Sprintf(":%d", *port), app.NewServer(*apiKey, apis, logger))
|
go http.ListenAndServe(fmt.Sprintf(":%d", *port), app.NewServer(*apiKey, apis, logger))
|
||||||
|
logger.Info("server started")
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
|
||||||
<-c
|
<-c
|
||||||
|
|
||||||
|
logger.Info("server stopped")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue