mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
fix(shutdown): fix crash when shutting down before server and task scheduler have started. (#2148)
init shutdown routine after controller.Init() check for nil values before stopping http server and task scheduler. Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
@@ -370,13 +370,18 @@ func (c *Controller) LoadNewConfig(newConfig *config.Config) {
|
||||
|
||||
func (c *Controller) Shutdown() {
|
||||
c.StopBackgroundTasks()
|
||||
ctx := context.Background()
|
||||
_ = c.Server.Shutdown(ctx)
|
||||
|
||||
if c.Server != nil {
|
||||
ctx := context.Background()
|
||||
_ = c.Server.Shutdown(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// Will stop scheduler and wait for all tasks to finish their work.
|
||||
func (c *Controller) StopBackgroundTasks() {
|
||||
c.taskScheduler.Shutdown()
|
||||
if c.taskScheduler != nil {
|
||||
c.taskScheduler.Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) StartBackgroundTasks() {
|
||||
|
||||
Reference in New Issue
Block a user