Fix panic on influx shutdown.
Influx was shutdown before Poseidon was terminated. In that mean time the Profiling data has been written. Also in that mean time, a periodical influx event triggers a panic since influx is already shutdown. We implemented two changes, each fixing this scenario.
This commit is contained in:

committed by
Sebastian Serth

parent
5fe9b686c2
commit
a4599f2cf9
@ -215,12 +215,12 @@ func main() {
|
|||||||
initSentry(&config.Config.Sentry, config.Config.Profiling.Enabled)
|
initSentry(&config.Config.Sentry, config.Config.Profiling.Enabled)
|
||||||
defer shutdownSentry()
|
defer shutdownSentry()
|
||||||
|
|
||||||
stopProfiling := initProfiling(config.Config.Profiling)
|
|
||||||
defer stopProfiling()
|
|
||||||
|
|
||||||
cancel := monitoring.InitializeInfluxDB(&config.Config.InfluxDB)
|
cancel := monitoring.InitializeInfluxDB(&config.Config.InfluxDB)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
stopProfiling := initProfiling(config.Config.Profiling)
|
||||||
|
defer stopProfiling()
|
||||||
|
|
||||||
server := initServer()
|
server := initServer()
|
||||||
go runServer(server)
|
go runServer(server)
|
||||||
shutdownOnOSSignal(server)
|
shutdownOnOSSignal(server)
|
||||||
|
@ -82,6 +82,7 @@ func InitializeInfluxDB(db *config.InfluxDB) (cancel func()) {
|
|||||||
// Flush the influx client on shutdown.
|
// Flush the influx client on shutdown.
|
||||||
cancel = func() {
|
cancel = func() {
|
||||||
influxClient.Flush()
|
influxClient.Flush()
|
||||||
|
influxClient = nil
|
||||||
client.Close()
|
client.Close()
|
||||||
}
|
}
|
||||||
return cancel
|
return cancel
|
||||||
@ -149,7 +150,7 @@ func ChangedPrewarmingPoolSize(id dto.EnvironmentID, count uint) {
|
|||||||
WriteInfluxPoint(p)
|
WriteInfluxPoint(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteInfluxPoint schedules the indlux data point to be sent.
|
// WriteInfluxPoint schedules the influx data point to be sent.
|
||||||
func WriteInfluxPoint(p *write.Point) {
|
func WriteInfluxPoint(p *write.Point) {
|
||||||
if influxClient != nil {
|
if influxClient != nil {
|
||||||
p.AddTag("stage", config.Config.InfluxDB.Stage)
|
p.AddTag("stage", config.Config.InfluxDB.Stage)
|
||||||
|
Reference in New Issue
Block a user