-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (34 loc) · 819 Bytes
/
Copy pathmain.go
File metadata and controls
43 lines (34 loc) · 819 Bytes
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
36
37
38
39
40
41
42
43
// Copyright 2024 Seakee. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"github.com/seakee/go-api/app/config"
"log"
"os"
"os/signal"
"runtime"
"github.com/seakee/go-api/bootstrap"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
cfg, err := config.LoadConfig()
if err != nil {
log.Fatal("Loading cfg error: ", err)
}
a, err := bootstrap.NewApp(cfg)
if err != nil {
log.Fatal("New App error: ", err)
}
a.Start()
s := waitForSignal()
log.Println("Signal received, app closed.", s)
}
func waitForSignal() os.Signal {
signalChan := make(chan os.Signal, 1)
defer close(signalChan)
signal.Notify(signalChan, os.Kill, os.Interrupt)
s := <-signalChan
signal.Stop(signalChan)
return s
}