优化服务启动流程
This commit is contained in:
@@ -37,11 +37,7 @@ func New(config *Config) *Service {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Close() {
|
||||
s.cancel()
|
||||
}
|
||||
|
||||
func (s *Service) Run() {
|
||||
func (s *Service) Run() error {
|
||||
slog.Info("启动 fwd 服务")
|
||||
|
||||
errQuit := make(chan struct{}, 2)
|
||||
@@ -79,7 +75,7 @@ func (s *Service) Run() {
|
||||
slog.Info("fwd 服务主动退出")
|
||||
case <-errQuit:
|
||||
slog.Warn("fwd 服务异常退出")
|
||||
s.Close()
|
||||
s.Stop()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
@@ -103,4 +99,10 @@ func (s *Service) Run() {
|
||||
slog.Debug("转发服务已关闭")
|
||||
wg.Wait()
|
||||
slog.Info("fwd 服务已退出")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) Stop() {
|
||||
s.cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user