forked from tsuru/tsuru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (48 loc) · 1.23 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
// Copyright 2014 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"os"
"os/signal"
"syscall"
"github.com/tsuru/config"
"github.com/tsuru/tsuru/cmd"
"github.com/tsuru/tsuru/provision"
_ "github.com/tsuru/tsuru/provision/docker"
)
const defaultConfigPath = "/etc/tsuru/tsuru.conf"
var configPath = defaultConfigPath
func buildManager() *cmd.Manager {
m := cmd.NewManager("tsr", "0.8.2", "", os.Stdout, os.Stderr, os.Stdin, nil)
m.Register(&tsrCommand{Command: &apiCmd{}})
m.Register(&tsrCommand{Command: tokenCmd{}})
registerProvisionersCommands(m)
return m
}
func registerProvisionersCommands(m *cmd.Manager) {
provisioners := provision.Registry()
for _, p := range provisioners {
if c, ok := p.(cmd.Commandable); ok {
commands := c.Commands()
for _, cmd := range commands {
m.Register(&tsrCommand{Command: cmd})
}
}
}
}
func listenSignals() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP)
go func() {
for _ = range ch {
config.ReadConfigFile(configPath)
}
}()
}
func main() {
config.ReadConfigFile(configPath)
listenSignals()
m := buildManager()
m.Run(os.Args[1:])
}