package main import ( "flag" "os" "os/signal" "syscall" cc "git.loafle.net/commons_go/config" "git.loafle.net/commons_go/logging" oocc "git.loafle.net/overflow/overflow_commons_go/config" "git.loafle.net/overflow/overflow_gateway_webapp/server" "git.loafle.net/overflow/overflow_gateway_webapp/servlet" oogwc "git.loafle.net/overflow/overflow_gateway_websocket/config" oogws "git.loafle.net/overflow/overflow_gateway_websocket/server" ) 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) } } func main() { 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 { logging.Logger().Infof("Server: Start error %v", err) return } }() select { case signal := <-stop: logging.Logger().Infof("Got signal: %v\n", signal) } servlet.ServletDestroy() s.Stop() logging.Logger().Infof("Server stopped") }