56 lines
932 B
Go
56 lines
932 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"git.loafle.net/commons_go/config"
|
|
"git.loafle.net/commons_go/logging"
|
|
"git.loafle.net/overflow/overflow_gateway_app/conf"
|
|
"git.loafle.net/overflow/overflow_gateway_app/external"
|
|
"git.loafle.net/overflow/overflow_gateway_app/server"
|
|
)
|
|
|
|
func init() {
|
|
configPath := flag.String("config", "./", "The path of config file")
|
|
|
|
flag.Parse()
|
|
|
|
config.SetConfigPath(*configPath)
|
|
if err := config.Load(&conf.Config, "config.json"); nil != err {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
defer logging.Logger().Sync()
|
|
|
|
external.ExternalInit()
|
|
|
|
s := server.New()
|
|
|
|
stop := make(chan os.Signal)
|
|
signal.Notify(stop, syscall.SIGINT)
|
|
|
|
go func() {
|
|
if err := s.Start(); nil != err {
|
|
log.Printf("Server: Start error %v", err)
|
|
return
|
|
}
|
|
}()
|
|
|
|
select {
|
|
case signal := <-stop:
|
|
fmt.Printf("Got signal: %v\n", signal)
|
|
}
|
|
|
|
external.ExternalDestroy()
|
|
|
|
s.Stop()
|
|
|
|
}
|