orbiter/main.go
Gianluca Arbezzano be8f301328 Add basic commands to help with debugging
Add new API call to get all the autoscalers currently managed by
orbiter:

```
curl http://localhost:8000/autoscaler
```

Add command into the CLI to get this list

```
export ORBITER_HOST=http://localhost:8000 orbiter autoscler ls
```

Add command into the CLI to print all the events fired by the daemon:

```
export ORBITER_HOST=http://localhost:8000 orbiter system events
```
2017-03-18 19:49:17 +00:00

34 lines
709 B
Go

package main
import (
"os"
"github.com/Sirupsen/logrus"
"github.com/gianarb/orbiter/cmd"
"github.com/gianarb/orbiter/utils/hook"
"github.com/mitchellh/cli"
)
func main() {
eventChannel := make(chan *logrus.Entry)
logrus.AddHook(hook.NewChannelHook(eventChannel))
c := cli.NewCLI("orbiter", "0.0.0")
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"daemon": func() (cli.Command, error) {
return &cmd.DaemonCmd{eventChannel}, nil
},
"autoscaler ls": func() (cli.Command, error) {
return &cmd.AutoscalerListCmd{}, nil
},
"system events": func() (cli.Command, error) {
return &cmd.SystemEventsCmd{}, nil
},
}
exitStatus, _ := c.Run()
os.Exit(exitStatus)
}