From e380cb888f7876ac19d88e2c85ef19fb3c6cfbf3 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Wed, 22 Jan 2025 22:13:54 +0100 Subject: [PATCH] fix restart inbounds after commit db changes --- backend/service/client.go | 2 +- backend/service/config.go | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/backend/service/client.go b/backend/service/client.go index b782836..82cdbe1 100644 --- a/backend/service/client.go +++ b/backend/service/client.go @@ -307,7 +307,7 @@ func (s *ClientService) DepleteClients() error { if err == nil { tx.Commit() if len(inboundIds) > 0 && corePtr.IsRunning() { - err1 := s.InboundService.RestartInbounds(tx, inboundIds) + err1 := s.InboundService.RestartInbounds(db, inboundIds) if err1 != nil { logger.Error("unable to restart inbounds: ", err1) } diff --git a/backend/service/config.go b/backend/service/config.go index 138221d..4551bfa 100644 --- a/backend/service/config.go +++ b/backend/service/config.go @@ -127,6 +127,16 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU defer func() { if err == nil { tx.Commit() + if len(inboundIds) > 0 && corePtr.IsRunning() { + err1 := s.InboundService.RestartInbounds(db, inboundIds) + if err1 != nil { + logger.Error("unable to restart inbounds: ", err1) + } + } + // Try to start core if it is not running + if !corePtr.IsRunning() { + s.StartCore("") + } } else { tx.Rollback() } @@ -214,17 +224,6 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU objs = append(objs, "inbounds") } - if len(inboundIds) > 0 && corePtr.IsRunning() { - err1 := s.InboundService.RestartInbounds(tx, inboundIds) - if err1 != nil { - logger.Error("unable to restart inbounds: ", err1) - } - } - // Try to start core if it is not running - if !corePtr.IsRunning() { - s.StartCore("") - } - return objs, nil }