-
Notifications
You must be signed in to change notification settings - Fork 108
/
main.go
55 lines (43 loc) · 1.14 KB
/
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
47
48
49
50
51
52
53
54
55
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package main
import (
"flag"
"log"
"os"
"os/signal"
"syscall"
"github.com/mattermost/mattermost-push-proxy/internal/version"
"github.com/mattermost/mattermost-push-proxy/server"
)
var (
flagConfigFile string
falgVersion bool
)
func main() {
flag.StringVar(&flagConfigFile, "config", "mattermost-push-proxy.json", "")
flag.BoolVar(&falgVersion, "version", false, "")
flag.Parse()
if falgVersion {
if err := version.GetVersion(); err != nil {
log.Fatal(err)
}
os.Exit(0)
}
fileName := server.FindConfigFile(flagConfigFile)
cfg, err := server.LoadConfig(fileName)
if err != nil {
// We just do a hard exit, because the app won't be able to start without a config.
log.Fatal(err)
}
logger := server.NewLogger(cfg)
logger.Info("Loading " + fileName)
srv := server.New(cfg, logger)
srv.Start()
// wait for kill signal before attempting to gracefully shutdown
// the running service
stopChan := make(chan os.Signal, 1)
signal.Notify(stopChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-stopChan
srv.Stop()
}