新增单进程模式

This commit is contained in:
flswld committed 2024-07-18 00:56:30 +08:00
1 parent 669a524153
commit 6136e57919
73 files changed
+1900 -153

No files matched your search

+11 -7
View File
@@ -14,13 +14,16 @@ import (
"hk4e/pkg/logger"
)
func Run(ctx context.Context, configFile string) error {
config.InitConfig(configFile)
logger.InitLogger("gm")
func Run(ctx context.Context) error {
if !config.GetConfig().Hk4e.StandaloneModeEnable {
logger.InitLogger("gm")
defer func() {
logger.CloseLogger()
}()
}
logger.Warn("gm start")
defer func() {
logger.CloseLogger()
logger.Warn("gm exit")
}()
// natsrpc client
@@ -35,7 +38,9 @@ func Run(ctx context.Context, configFile string) error {
_ = controller.NewController(discoveryClient, messageQueue)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
if !config.GetConfig().Hk4e.StandaloneModeEnable {
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
}
for {
select {
case <-ctx.Done():
@@ -44,7 +49,6 @@ func Run(ctx context.Context, configFile string) error {
logger.Warn("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
logger.Warn("gm exit")
return nil
case syscall.SIGHUP:
default: