-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
59 lines (46 loc) · 1.21 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
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"runtime"
"github.com/matthewvalimaki/cas-server/admin"
"github.com/matthewvalimaki/cas-server/tools"
"github.com/matthewvalimaki/cas-server/spec"
"github.com/matthewvalimaki/cas-server/test"
"github.com/matthewvalimaki/cas-server/storage"
)
func main() {
// get configuration location
var configPath string
flag.StringVar(&configPath, "config", "", "Path to config file")
flag.Parse()
if configPath == "" {
tools.Log("Command line argument `-config` must be set")
return
}
config, err := tools.NewConfig(configPath)
if err != nil {
tools.LogError(err.Error())
return
}
admin.SupportServices(config)
storage := storage.NewMemoryStorage()
spec.SupportV1(storage, config)
test.SupportTest()
startServers(config)
// keep server running until interrupt
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
os.Exit(1)
}()
for {
runtime.Gosched()
time.Sleep(5 * time.Second)
}
}