cfha/main.go

40 lines
665 B
Go
Raw Permalink Normal View History

2015-08-21 17:27:26 +00:00
package main
import (
"log"
"fmt"
"os"
"syscall"
2015-08-21 17:27:26 +00:00
"io/ioutil"
"os/signal"
2015-08-21 17:27:26 +00:00
"encoding/json"
2015-08-23 03:20:58 +00:00
"./core"
"./engine"
2015-08-21 17:27:26 +00:00
)
func main() {
file, err := ioutil.ReadFile("./config.json")
if err != nil {
log.Fatal(fmt.Sprintf("%v\n", err))
}
2015-08-23 03:20:58 +00:00
c := core.Config{}
2015-08-21 17:27:26 +00:00
json.Unmarshal(file, &c)
2015-08-23 03:20:58 +00:00
engines := make([]*core.Engine, 0)
2015-08-23 03:20:58 +00:00
for _, check := range c.Checks {
engines = append(engines, engine.EngineFromConfig(check))
}
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
<-sigs
log.Print(fmt.Sprintf("Stopping."))
2015-08-23 03:20:58 +00:00
for _, engine := range engines {
engine.Stop()
2015-08-21 17:27:26 +00:00
}
log.Print("Exiting.")
2015-08-21 17:27:26 +00:00
}