mirror of
https://github.com/henrygd/beszel.git
synced 2026-08-19 16:57:47 +02:00
The staggered Initialize goroutine kept calling AddSystem after the hub had been torn down, which spawned StartUpdater goroutines that later dereferenced a nil DB inside PocketBase. Track a manager-level context that RemoveAllSystems cancels, abort the staggered loop on shutdown, and refuse AddSystem once the manager is stopped.
This commit is contained in:
@@ -111,6 +111,11 @@ func (sm *SystemManager) SetSystemStatusInDB(systemID string, status string) boo
|
||||
|
||||
// TESTING ONLY: RemoveAllSystems removes all systems from the store
|
||||
func (sm *SystemManager) RemoveAllSystems() {
|
||||
// Signal shutdown first so any in-flight Initialize staggered-start goroutine
|
||||
// stops adding new systems against a hub that is about to be torn down. See #1950.
|
||||
if sm.cancel != nil {
|
||||
sm.cancel()
|
||||
}
|
||||
for _, system := range sm.systems.GetAll() {
|
||||
sm.RemoveSystem(system.Id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user