mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
fixed proper stop and removal of subscriber procs
This commit is contained in:
parent
11b0444929
commit
3458e655c0
1 changed files with 19 additions and 0 deletions
19
process.go
19
process.go
|
@ -227,6 +227,25 @@ func (p process) spawnWorker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
p.natsSubscription = p.subscribeMessages()
|
p.natsSubscription = p.subscribeMessages()
|
||||||
|
|
||||||
|
// We also need to be able to remove all the information about this process
|
||||||
|
// when the process context is canceled.
|
||||||
|
go func() {
|
||||||
|
<-p.ctx.Done()
|
||||||
|
err := p.natsSubscription.Unsubscribe()
|
||||||
|
if err != nil {
|
||||||
|
er := fmt.Errorf("error: spawnWorker: got <-ctx.Done, but unable to unsubscribe natsSubscription failed: %v", err)
|
||||||
|
p.errorKernel.errSend(p, Message{}, er)
|
||||||
|
p.errorKernel.logConsoleOnlyIfDebug(er, p.configuration)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.processes.active.mu.Lock()
|
||||||
|
delete(p.processes.active.procNames, p.processName)
|
||||||
|
p.processes.active.mu.Unlock()
|
||||||
|
|
||||||
|
log.Printf("Successfully stopped process: %v\n", p.processName)
|
||||||
|
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add information about the new process to the started processes map.
|
// Add information about the new process to the started processes map.
|
||||||
|
|
Loading…
Reference in a new issue