Use routine.Manager in router
This commit is contained in:
parent
23f7497622
commit
3c7b964cfe
@ -23,7 +23,7 @@ const banner = "\n" +
|
||||
" '/"
|
||||
|
||||
func main () {
|
||||
// setup logging
|
||||
// set up logging
|
||||
logDir := os.Getenv("HNAKRA_LOG_DIR")
|
||||
if logDir != "" {
|
||||
logger, err := rotate.New(logDir)
|
||||
@ -33,7 +33,6 @@ func main () {
|
||||
rcon := rcon.New("/debug/rcon")
|
||||
originalWriter := log.Writer()
|
||||
log.SetOutput(io.MultiWriter(originalWriter, rcon))
|
||||
|
||||
log.Println(banner)
|
||||
|
||||
// load config
|
||||
@ -55,10 +54,18 @@ func main () {
|
||||
})
|
||||
rcon.SetConfig(conf)
|
||||
|
||||
// start servers
|
||||
// set up servers
|
||||
log.Println("... starting up")
|
||||
manager := routines.Manager { RestartDeadline: time.Second * 8 }
|
||||
rout := router.New(conf)
|
||||
srvhnakra := &srvhnakra.Server { Config: conf, Router: rout }
|
||||
manager.Append(srvhnakra.ListenAndServe)
|
||||
if conf.HTTPSEnable() {
|
||||
srvhttps := &srvhttps.Server { Config: conf, Handler: rout }
|
||||
manager.Append(srvhttps.ListenAndServe)
|
||||
}
|
||||
|
||||
// set up rcon
|
||||
rcon.SetRouter(rout)
|
||||
if conf.RconEnable() {
|
||||
err = rout.HTTPMux().Handle("@/debug/rcon/", rcon)
|
||||
@ -66,12 +73,9 @@ func main () {
|
||||
} else {
|
||||
log.SetOutput(originalWriter)
|
||||
}
|
||||
if conf.HTTPSEnable() {
|
||||
srvhttps := &srvhttps.Server { Config: conf, Handler: rout }
|
||||
go httpsRoutine(srvhttps)
|
||||
}
|
||||
|
||||
err = srvhnakra.ListenAndServe()
|
||||
|
||||
// run servers
|
||||
err = manager.Run()
|
||||
if err != nil { log.Println("XXX", err) }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user