diff --git a/app/api/api.go b/app/api/api.go index 7a013db9..69db9088 100644 --- a/app/api/api.go +++ b/app/api/api.go @@ -1734,20 +1734,6 @@ func (a *api) stop() { a.cluster.Shutdown() } - if a.iam != nil { - a.iam.Close() - } - - if a.update != nil { - a.update.Stop() - a.update = nil - } - - if a.service != nil { - a.service.Stop() - a.service = nil - } - // Stop all restream processes if a.restream != nil { logger.Info().Log("Stopping all processes ...") @@ -1755,38 +1741,6 @@ func (a *api) stop() { a.restream = nil } - if a.process != nil { - a.process.Stop() - a.process = nil - } - - // Stop the session tracker - if a.sessions != nil { - a.sessions.UnregisterAll() - a.sessions.Close() - a.sessions = nil - } - - // Unregister all collectors - if a.metrics != nil { - a.metrics.UnregisterAll() - a.metrics = nil - } - - if a.prom != nil { - a.prom.UnregisterAll() - a.prom = nil - } - - // Free the cached objects - if a.cache != nil { - a.cache.Purge() - a.cache = nil - } - - // Free the S3 mounts - a.s3fs = map[string]fs.Filesystem{} - // Stop the SRT server if a.srtserver != nil { a.log.logger.srt.Info().Log("Stopping ...") @@ -1835,11 +1789,56 @@ func (a *api) stop() { a.sidecarserver = nil } + if a.iam != nil { + a.iam.Close() + } + + if a.update != nil { + a.update.Stop() + a.update = nil + } + + if a.service != nil { + a.service.Stop() + a.service = nil + } + + if a.process != nil { + a.process.Stop() + a.process = nil + } + + // Unregister all collectors + if a.metrics != nil { + a.metrics.UnregisterAll() + a.metrics = nil + } + + if a.prom != nil { + a.prom.UnregisterAll() + a.prom = nil + } + + // Free the cached objects + if a.cache != nil { + a.cache.Purge() + a.cache = nil + } + + // Free the S3 mounts + a.s3fs = map[string]fs.Filesystem{} + // Stop resource observer if a.resources != nil { a.resources.Stop() } + // Stop the session tracker + if a.sessions != nil { + a.sessions.Close() + a.sessions = nil + } + // Stop the GC ticker if a.gcTickerStop != nil { a.gcTickerStop()