[service] Fix starting and stopping of SPN

This commit is contained in:
Daniel 2024-08-27 16:42:22 +02:00
parent 57f08eccd7
commit 7f0b5ca149
2 changed files with 6 additions and 4 deletions
service
spn/access

View file

@ -619,7 +619,7 @@ func (i *Instance) shutdown(exitCode int) {
// Stopping returns whether the instance is shutting down. // Stopping returns whether the instance is shutting down.
func (i *Instance) Stopping() bool { 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. // Stopped returns a channel that is triggered when the instance has shut down.

View file

@ -86,22 +86,24 @@ func start() error {
enabled := config.GetAsBool("spn/enable", false) enabled := config.GetAsBool("spn/enable", false)
if enabled() { if enabled() {
log.Info("spn: starting SPN")
module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker) module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker)
} else { } else {
log.Info("spn: stopping SPN")
module.mgr.Go("ensure SPN is stopped", module.instance.SPNGroup().EnsureStoppedWorker) module.mgr.Go("ensure SPN is stopped", module.instance.SPNGroup().EnsureStoppedWorker)
} }
return false, nil return false, nil
}) })
// Load tokens from database.
loadTokens()
// Check if we need to enable SPN now. // Check if we need to enable SPN now.
enabled := config.GetAsBool("spn/enable", false) enabled := config.GetAsBool("spn/enable", false)
if enabled() { if enabled() {
module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker) module.mgr.Go("ensure SPN is started", module.instance.SPNGroup().EnsureStartedWorker)
} }
// Load tokens from database.
loadTokens()
// Register new task. // Register new task.
module.updateAccountWorkerMgr.Delay(1 * time.Minute) module.updateAccountWorkerMgr.Delay(1 * time.Minute)
} }