2017-03-25 14:27:47 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"log"
|
2017-03-25 16:09:17 +01:00
|
|
|
"net/http"
|
2017-03-26 19:48:59 +02:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2017-03-25 16:09:17 +01:00
|
|
|
|
|
|
|
goji "goji.io"
|
|
|
|
|
|
|
|
http_api "github.com/genofire/hs_master-kss-monolith/http"
|
|
|
|
"github.com/genofire/hs_master-kss-monolith/models"
|
2017-03-25 14:27:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2017-03-25 16:09:17 +01:00
|
|
|
configFile string
|
|
|
|
config *models.Config
|
2017-03-25 14:27:47 +01:00
|
|
|
timestamps bool
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.BoolVar(×tamps, "timestamps", true, "print timestamps in output")
|
2017-03-25 16:09:17 +01:00
|
|
|
flag.StringVar(&configFile, "config", "config.conf", "path of configuration file (default:config.conf)")
|
2017-03-25 14:27:47 +01:00
|
|
|
flag.Parse()
|
|
|
|
|
2017-03-25 16:09:17 +01:00
|
|
|
// load config
|
|
|
|
config = models.ReadConfigFile(configFile)
|
|
|
|
|
2017-03-25 14:27:47 +01:00
|
|
|
if !timestamps {
|
|
|
|
log.SetFlags(0)
|
|
|
|
}
|
2017-03-25 16:09:17 +01:00
|
|
|
|
|
|
|
log.Println("Starting rezension monolith")
|
|
|
|
|
|
|
|
// Startwebsrver
|
|
|
|
router := goji.NewMux()
|
|
|
|
http_api.BindAPI(router)
|
2017-03-26 19:48:59 +02:00
|
|
|
srv := &http.Server{
|
|
|
|
Addr: config.WebserverBind,
|
|
|
|
Handler: router,
|
|
|
|
}
|
|
|
|
go srv.ListenAndServe()
|
|
|
|
|
|
|
|
// Wait for system signal
|
|
|
|
sigs := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
sig := <-sigs
|
|
|
|
|
|
|
|
// Stop services
|
|
|
|
srv.Close()
|
|
|
|
|
|
|
|
log.Println("received", sig)
|
2017-03-25 14:27:47 +01:00
|
|
|
}
|