59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
//"flag"
|
|
//oocc "git.loafle.net/commons/configuration-go"
|
|
"git.loafle.net/commons/logging-go"
|
|
"git.loafle.net/overflow/member_gateway_rpc/server"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
"context"
|
|
)
|
|
//
|
|
//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 init() {
|
|
logging.InitializeLogger("")
|
|
}
|
|
|
|
func main() {
|
|
s := server.New()
|
|
|
|
go func() {
|
|
err := s.ListenAndServe()
|
|
if nil != err {
|
|
log.Printf("err: %v", err)
|
|
}
|
|
}()
|
|
|
|
interrupt := make(chan os.Signal, 1)
|
|
signal.Notify(interrupt,
|
|
syscall.SIGKILL,
|
|
syscall.SIGSTOP,
|
|
syscall.SIGHUP,
|
|
syscall.SIGINT,
|
|
syscall.SIGTERM,
|
|
syscall.SIGQUIT)
|
|
|
|
<-interrupt
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
if err := s.Shutdown(ctx); err != nil {
|
|
logging.Logger().Errorf("error: %v", err)
|
|
}
|
|
}
|