File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Package main is the entry point for the k6 CLI application. It assembles all the crucial components for the running.
2
+ package main
3
+
4
+ import (
5
+ "fmt"
6
+ "os"
7
+ "os/signal"
8
+ "syscall"
9
+
10
+ "github.com/stfsy/go-api-kit/app/server"
11
+ "github.com/stfsy/go-api-kit/app/utils"
12
+ )
13
+
14
+ var logger = utils .NewLogger ("main" )
15
+
16
+ func main () {
17
+ startServerNonBlocking ()
18
+ stopServerAfterSignal ()
19
+ }
20
+
21
+ func stopServerAfterSignal () {
22
+ sigChan := make (chan os.Signal , 1 )
23
+ signal .Notify (sigChan , syscall .SIGINT , syscall .SIGTERM )
24
+ <- sigChan
25
+
26
+ server .Stop ()
27
+
28
+ logger .Info ("Graceful shutdown complete." )
29
+ }
30
+
31
+ func startServerNonBlocking () {
32
+ go func () {
33
+ err := server .Start (nil , nil )
34
+ if err != nil {
35
+ panic (fmt .Errorf ("unable to start server %w" , err ))
36
+ }
37
+ }()
38
+ }
You can’t perform that action at this time.
0 commit comments