forked from UhuruSoftware/warden-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
85 lines (63 loc) · 1.57 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"flag"
"log"
"os"
"os/signal"
"runtime"
"syscall"
"github.com/cloudfoundry-incubator/cf-lager"
"github.com/cloudfoundry-incubator/garden/server"
Backend "github.com/uhurusoftware/warden-windows/backend"
)
var listenNetwork = flag.String(
"listenNetwork",
"tcp",
"how to listen on the address (unix, tcp, etc.)",
)
var listenAddr = flag.String(
"listenAddr",
"0.0.0.0:9876",
"address to listen on",
)
var containerGraceTime = flag.Duration(
"containerGraceTime",
0,
"time after which to destroy idle containers",
)
var containerRootPath = flag.String(
"containerRootPath",
"",
"directory in which to store container root directories",
)
var debug = flag.Bool(
"debug",
false,
"show low-level command output",
)
func main() {
flag.Parse()
maxProcs := runtime.NumCPU()
prevMaxProcs := runtime.GOMAXPROCS(maxProcs)
log.Println("set GOMAXPROCS to", maxProcs, "was", prevMaxProcs)
backend := Backend.New(*containerRootPath, nil)
log.Println("setting up backend")
log.Println("starting server; listening with", *listenNetwork, "on", *listenAddr)
graceTime := *containerGraceTime
logger := cf_lager.New("warden-winodws")
serverLogger := logger.Session("garden")
wardenServer := server.New(*listenNetwork, *listenAddr, graceTime, backend, serverLogger)
err := wardenServer.Start()
if err != nil {
log.Fatalln("failed to start:", err)
}
signals := make(chan os.Signal, 1)
go func() {
<-signals
log.Println("stopping...")
wardenServer.Stop()
os.Exit(0)
}()
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
select {}
}