Skip to content

Commit 4897777

Browse files
committed
chore: add main.go file
1 parent d5a90c8 commit 4897777

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

main.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)