-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (29 loc) · 770 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"context"
"log"
"log/slog"
"os"
"os/signal"
"github.com/programkingstar/task-management-go.git/api"
)
func initServer(ctx context.Context) error {
server := api.NewServer()
return server.Start(ctx)
}
// @version 1
// @title Notethingness API
// @description This is a sample server for Notethingness API.
// @host localhost:3000
// @BasePath /api
func main() {
serverCtx, stopCtx := signal.NotifyContext(context.Background(), os.Interrupt)
defer stopCtx()
err := initServer(serverCtx)
if err != nil {
log.Fatal("can't run the server: ", err)
slog.Error(" [ 💢Cannot run the server! ] " + "\nError: " + err.Error())
slog.ErrorContext(serverCtx, " [ 💢Cannot run the server! ] "+"\nError: "+err.Error())
os.Exit(1)
}
}