From 7f0b5ca1492799ae64c9d8dd43eb1fa3ecf8110a Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 27 Aug 2024 16:42:22 +0200 Subject: [PATCH] [service] Fix starting and stopping of SPN --- service/instance.go | 2 +- spn/access/module.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/service/instance.go b/service/instance.go index 8eab70eb..ad6e9dab 100644 --- a/service/instance.go +++ b/service/instance.go @@ -619,7 +619,7 @@ func (i *Instance) shutdown(exitCode int) { // Stopping returns whether the instance is shutting down. func (i *Instance) Stopping() bool { - return i.ctx.Err() == nil + return i.ctx.Err() != nil } // Stopped returns a channel that is triggered when the instance has shut down. diff --git a/spn/access/module.go b/spn/access/module.go index 2b076586..d49524f9 100644 --- a/spn/access/module.go +++ b/spn/access/module.go @@ -86,22 +86,24 @@ func start() error { enabled := config.GetAsBool("spn/enable", false) if enabled() { + log.Info("spn: starting SPN") module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker) } else { + log.Info("spn: stopping SPN") module.mgr.Go("ensure SPN is stopped", module.instance.SPNGroup().EnsureStoppedWorker) } return false, nil }) + // Load tokens from database. + loadTokens() + // Check if we need to enable SPN now. enabled := config.GetAsBool("spn/enable", false) if enabled() { module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker) } - // Load tokens from database. - loadTokens() - // Register new task. module.updateAccountWorkerMgr.Delay(1 * time.Minute) }