mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-15 21:42:26 +08:00
init commit
This commit is contained in:
17
water/cmd/application.toml
Normal file
17
water/cmd/application.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
http_port = 9001
|
||||
|
||||
[logger]
|
||||
level = "DEBUG"
|
||||
method = "CONSOLE"
|
||||
track_line = true
|
||||
|
||||
[air]
|
||||
addr = "air"
|
||||
port = 8086
|
||||
service_name = "water-auth"
|
||||
|
||||
[database]
|
||||
url = "root:flswld@(mysql:3306)/annie_water?charset=utf8&parseTime=True&loc=Local"
|
||||
|
||||
[light]
|
||||
port = 10002
|
||||
55
water/cmd/main.go
Normal file
55
water/cmd/main.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flswld.com/common/config"
|
||||
"flswld.com/light"
|
||||
"flswld.com/logger"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
"water/controller"
|
||||
"water/dao"
|
||||
"water/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
filePath := "./application.toml"
|
||||
config.InitConfig(filePath)
|
||||
|
||||
logger.InitLogger()
|
||||
logger.LOG.Info("water start")
|
||||
|
||||
httpProvider := light.NewHttpProvider()
|
||||
|
||||
// 用户服务
|
||||
rpcUserConsumer := light.NewRpcConsumer("annie-user-app")
|
||||
|
||||
db := dao.NewDao()
|
||||
|
||||
svc := service.NewService(db, rpcUserConsumer)
|
||||
rpcSvc := service.NewRpcService(db, svc)
|
||||
|
||||
rpcProvider := light.NewRpcProvider(rpcSvc)
|
||||
|
||||
_ = controller.NewController(svc)
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
|
||||
for {
|
||||
s := <-c
|
||||
logger.LOG.Info("get a signal %s", s.String())
|
||||
switch s {
|
||||
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
|
||||
rpcProvider.CloseRpcProvider()
|
||||
rpcUserConsumer.CloseRpcConsumer()
|
||||
httpProvider.CloseHttpProvider()
|
||||
logger.LOG.Info("water exit")
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user