2017-11-23 10:33:19 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-03-22 09:15:12 +00:00
|
|
|
"flag"
|
2017-11-23 10:33:19 +00:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2018-03-16 03:17:14 +00:00
|
|
|
|
2018-03-22 09:15:12 +00:00
|
|
|
cc "git.loafle.net/commons_go/config"
|
2018-03-16 03:17:14 +00:00
|
|
|
"git.loafle.net/commons_go/logging"
|
2018-03-22 09:15:12 +00:00
|
|
|
oocc "git.loafle.net/overflow/overflow_commons_go/config"
|
2017-11-23 10:33:19 +00:00
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/server"
|
|
|
|
"git.loafle.net/overflow/overflow_gateway_probe/servlet"
|
2018-03-22 09:15:12 +00:00
|
|
|
oogwc "git.loafle.net/overflow/overflow_gateway_websocket/config"
|
2018-03-16 03:17:14 +00:00
|
|
|
oogws "git.loafle.net/overflow/overflow_gateway_websocket/server"
|
2017-11-23 10:33:19 +00:00
|
|
|
)
|
|
|
|
|
2018-03-22 09:15:12 +00:00
|
|
|
var (
|
|
|
|
configDir *string
|
|
|
|
logConfigPath *string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
configDir = oocc.FlagConfigDir("./")
|
|
|
|
logConfigPath = oocc.FlagLogConfigFilePath("")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
logging.InitializeLogger(*logConfigPath)
|
|
|
|
|
|
|
|
cc.SetConfigPath(*configDir)
|
|
|
|
if err := cc.Load(&oogwc.Config, oocc.ConfigFileName); nil != err {
|
|
|
|
logging.Logger().Panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-11-23 10:33:19 +00:00
|
|
|
|
2018-03-22 09:15:12 +00:00
|
|
|
func main() {
|
2017-11-23 10:33:19 +00:00
|
|
|
defer logging.Logger().Sync()
|
|
|
|
|
|
|
|
sh := server.NewServerHandler()
|
|
|
|
servlet.ServletInit(sh)
|
|
|
|
|
|
|
|
s := oogws.New(sh)
|
|
|
|
|
|
|
|
stop := make(chan os.Signal)
|
|
|
|
signal.Notify(stop, syscall.SIGINT)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
if err := s.Start(); nil != err {
|
2018-03-22 09:15:12 +00:00
|
|
|
logging.Logger().Infof("Server: Start error %v", err)
|
2017-11-23 10:33:19 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
case signal := <-stop:
|
2018-03-22 09:15:12 +00:00
|
|
|
logging.Logger().Infof("Got signal: %v", signal)
|
2017-11-23 10:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
servlet.ServletDestroy()
|
|
|
|
|
|
|
|
s.Stop()
|
2018-03-22 09:15:12 +00:00
|
|
|
|
|
|
|
logging.Logger().Infof("Server stopped")
|
2017-11-23 10:33:19 +00:00
|
|
|
}
|