Create & Init Project...
This commit is contained in:
54
app/interface/main/activity/cmd/main.go
Normal file
54
app/interface/main/activity/cmd/main.go
Normal file
@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"go-common/app/interface/main/activity/conf"
|
||||
"go-common/app/interface/main/activity/http"
|
||||
rpc "go-common/app/interface/main/activity/rpc/server"
|
||||
"go-common/app/interface/main/activity/service/like"
|
||||
ecode "go-common/library/ecode/tip"
|
||||
"go-common/library/log"
|
||||
"go-common/library/net/trace"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if err := conf.Init(); err != nil {
|
||||
log.Error("conf.Init() error(%v)", err)
|
||||
panic(err)
|
||||
}
|
||||
// init log
|
||||
log.Init(conf.Conf.Log)
|
||||
trace.Init(conf.Conf.Tracer)
|
||||
defer trace.Close()
|
||||
defer log.Close()
|
||||
log.Info("activity start")
|
||||
// ecode
|
||||
ecode.Init(conf.Conf.Ecode)
|
||||
// service init
|
||||
svr := like.New(conf.Conf)
|
||||
rpcSvr := rpc.New(conf.Conf, svr)
|
||||
http.Init(conf.Conf)
|
||||
// init signal
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
|
||||
for {
|
||||
s := <-c
|
||||
log.Info("activity get a signal %s", s.String())
|
||||
switch s {
|
||||
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
|
||||
rpcSvr.Close()
|
||||
http.CloseService()
|
||||
log.Info("activity exit")
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
// TODO reload
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user