genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/cmd/review/main.go

57 lines
1.0 KiB
Go
Raw Normal View History

2017-03-25 14:27:47 +01:00
package main
import (
"flag"
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"
web "github.com/genofire/hs_master-kss-monolith/http"
2017-03-30 16:09:44 +02:00
"github.com/genofire/hs_master-kss-monolith/lib/database"
"github.com/genofire/hs_master-kss-monolith/lib/log"
2017-03-25 16:09:17 +01:00
"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
)
func main() {
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)
log.Log.Info("Starting rezension monolith")
2017-03-25 16:09:17 +01:00
2017-03-30 16:09:44 +02:00
err := database.Open(config.Database)
if err != nil{
log.Log.Panic(err)
}
2017-03-25 16:09:17 +01:00
// Startwebsrver
router := goji.NewMux()
web.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()
2017-03-30 16:09:44 +02:00
database.Close()
2017-03-26 19:48:59 +02:00
log.Log.Info("received", sig)
2017-03-25 14:27:47 +01:00
}