-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (35 loc) · 836 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
36
37
38
39
package main
import (
"context"
"github.com/joho/godotenv"
"gitlab.com/crypto_project/core/strategy_service/src/server"
"gitlab.com/crypto_project/core/strategy_service/src/service"
"log"
"os"
"os/signal"
"sync"
"syscall"
)
func init() {
err := godotenv.Load()
if err != nil {
log.Print("Error loading .env file") // TODO (Alisher): mb panic with no env?
}
}
func main() {
ctx := context.Background()
ctx, stop := signal.NotifyContext(ctx, syscall.SIGTERM, syscall.SIGINT) // k8s sends SIGTERM and waits
defer stop()
go func() {
<-ctx.Done()
log.Println("Brute shutdown.")
os.Exit(0)
}()
var wg sync.WaitGroup // TODO: init top-level context
wg.Add(1)
go server.RunServer(&wg)
wg.Add(1)
isLocalBuild := os.Getenv("LOCAL") == "true"
go service.GetStrategyService().Init(&wg, isLocalBuild)
wg.Wait()
}