diff --git a/internal/app/app_verification.go b/internal/app/app_verification.go index a29e0c0..f626364 100644 --- a/internal/app/app_verification.go +++ b/internal/app/app_verification.go @@ -98,17 +98,29 @@ func Run(cfg *config.Config, build Build) { CustomerServiceHost: cfg.CustomerRPCHost, })) - httpSrv := server.NewHTTP(server.ServerConfig{ + userSrv := server.NewHTTP(server.ServerConfig{ Logger: logger, - Controllers: []server.Controller{cons.VerificationUser, cons.VerificationAdmin}, + Controllers: []server.Controller{cons.VerificationUser}, + HLogger: loggerHlog, + }) + + adminSrv := server.NewHTTP(server.ServerConfig{ + Logger: logger, + Controllers: []server.Controller{cons.VerificationAdmin}, HLogger: loggerHlog, }) go func() { - if err := httpSrv.Start(cfg.HttpAddress); err != nil { + if err := userSrv.Start(cfg.HttpAddressUser); err != nil { logger.Fatal("Server startup error", zap.Error(err)) } }() - gracefulShutdown(ctx, logger, httpSrv, mongoDB) + go func() { + if err := adminSrv.Start(cfg.HttpAddressAdmin); err != nil { + logger.Fatal("Server startup error", zap.Error(err)) + } + }() + + gracefulShutdown(ctx, logger, []*server.Server{userSrv, adminSrv}, mongoDB) } diff --git a/internal/app/shutdown.go b/internal/app/shutdown.go index 0764770..dd76d4f 100644 --- a/internal/app/shutdown.go +++ b/internal/app/shutdown.go @@ -10,7 +10,7 @@ import ( "syscall" ) -func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrv *server.Server, mongoDB *mongo.Database) { +func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrvs []*server.Server, mongoDB *mongo.Database) { interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM) killSignal := <-interrupt @@ -21,8 +21,10 @@ func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrv *server.S logger.Info("AppTerminated") } - if err := httpSrv.Shutdown(ctx); err != nil { - logger.Error("HttpServerShutdown", zap.Error(err)) + for _, srv := range httpSrvs { + if err := srv.Shutdown(ctx); err != nil { + logger.Error("HttpServerShutdown", zap.Error(err)) + } } if err := mongoDB.Client().Disconnect(ctx); err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index 3aadbd2..c39555f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,7 +8,8 @@ import ( type Config struct { TelegramToken string `env:"TELEGRAM_TOKEN,required"` TelegramChannelID int64 `env:"TELEGRAM_CHANNEL_ID,required"` - HttpAddress string `env:"HTTP_ADDRESS,required"` + HttpAddressUser string `env:"HTTP_ADDRESS_USER,required"` + HttpAddressAdmin string `env:"HTTP_ADDRESS_ADMIN,required"` MongoHost string `env:"MONGO_HOST,required"` MongoPort string `env:"MONGO_PORT,required"` MongoUser string `env:"MONGO_USER,required"` diff --git a/recover.bolt b/recover.bolt deleted file mode 100644 index 0187664..0000000 Binary files a/recover.bolt and /dev/null differ diff --git a/test.env b/test.env index 83ebd06..6a89eaf 100644 --- a/test.env +++ b/test.env @@ -1,6 +1,7 @@ TELEGRAM_TOKEN=6712573453:AAFbioUuXf0Te73MUCqa0_h09qEQ1iQREas TELEGRAM_CHANNEL_ID=542073142 -HTTP_ADDRESS=0.0.0.0:8080 +HTTP_ADDRESS_USER=0.0.0.0:8080 +HTTP_ADDRESS_ADMIN=0.0.0.0:8081 MONGO_HOST=localhost MONGO_PORT=27020 MONGO_USER=test diff --git a/tests/e2e/get_verify_admin_test.go b/tests/e2e/get_verify_admin_test.go index e353111..4e3eca8 100644 --- a/tests/e2e/get_verify_admin_test.go +++ b/tests/e2e/get_verify_admin_test.go @@ -11,7 +11,7 @@ import ( ) func Test_GetVerifyAdmin(t *testing.T) { - url := "http://localhost:8080/verification/64e53ed187392e122e5d3d50" + url := "http://localhost:8081/verification/64e53ed187392e122e5d3d50" client := fiber.AcquireClient() token, err := helpers.CreateJwt("64e53ed187392e122e5d3d51") @@ -31,7 +31,7 @@ func Test_GetVerifyAdmin(t *testing.T) { assert.NoError(t, err) fmt.Println(resp) - url = "http://localhost:8080/verification" + url = "http://localhost:8081/verification" client2 := fiber.AcquireClient() req := models.ReqSetVerification{