Change core shutdown sequence

Now the cluster, restreamer (processes), and the servers (HTTP, HTTP, RTMP, SRT)
are shutdown first, then any other services. Before, e.g. the session collector
was closed very early before the servers. This would have lead to loss of a few
sessions.
This commit is contained in:
Ingo Oppermann
2023-07-04 12:35:08 +02:00
parent 3e1c934f2c
commit a8965cdec7

View File

@@ -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()