-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (36 loc) · 991 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
40
41
42
43
44
45
46
package main
import (
"flag"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/google/logger"
"github.com/joho/godotenv"
"github.com/viniciusbds/arrebol-pb-resource-manager/autoscaler"
"github.com/viniciusbds/arrebol-pb-resource-manager/storage"
)
func main() {
var wait time.Duration
flag.DurationVar(&wait, "graceful_timeout", time.Second*15, "the duration for which the server "+
"gracefully wait for existing connections to finish - e.g. 15s or 1m")
err := godotenv.Load()
if err != nil {
logger.Errorln(err.Error())
}
flag.Parse()
s := storage.New(os.Getenv("DATABASE_ADDRESS"), os.Getenv("DATABASE_PORT"), os.Getenv("DATABASE_USER"),
os.Getenv("DATABASE_NAME"), os.Getenv("DATABASE_PASSWORD"))
s.Setup()
defer s.Driver().Close()
// Shutdown gracefully
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt, syscall.SIGTERM)
<-sigs
log.Println("Shutting down service")
autoscaler.Stop()
}()
autoscaler.Start()
}