forked from dailymotion-oss/osiris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (41 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
package main
import (
"flag"
"strings"
"time"
"github.com/golang/glog"
"github.com/dailymotion-oss/osiris/cmd"
"github.com/dailymotion-oss/osiris/pkg/signals"
)
func main() {
const usageMsg = `usage: must specify Osiris component to start using ` +
`argument "activator", "endpoints-controller", "endpoints-hijacker", ` +
`"proxy", "proxy-injector", or "zeroscaler"`
// We need to parse flags for glog-related options to take effect
flag.Parse()
if len(flag.Args()) != 1 {
glog.Fatal(usageMsg)
}
// This context will automatically be canceled on SIGINT or SIGTERM.
ctx := signals.Context()
switch strings.ToLower(flag.Arg(0)) {
case "activator":
cmd.RunActivator(ctx)
case "endpoints-controller":
cmd.RunEndpointsController(ctx)
case "endpoints-hijacker":
cmd.RunEndpointsHijacker(ctx)
case "proxy":
cmd.RunProxy(ctx)
case "proxy-injector":
cmd.RunProxyInjector(ctx)
case "zeroscaler":
cmd.RunZeroScaler(ctx)
default:
glog.Fatal(usageMsg)
}
// A short grace period
shutdownDuration := 5 * time.Second
glog.Infof("allowing %s for graceful shutdown to complete", shutdownDuration)
<-time.After(shutdownDuration)
}