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:
@@ -41,8 +41,6 @@ func signalHandler(ctlr *api.Controller, sigCh chan os.Signal) {
|
||||
|
||||
// gracefully shutdown http server
|
||||
ctlr.Shutdown() //nolint: contextcheck
|
||||
|
||||
close(sigCh)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +59,6 @@ func initShutDownRoutine(ctlr *api.Controller) {
|
||||
func (hr *HotReloader) Start() {
|
||||
done := make(chan bool)
|
||||
|
||||
initShutDownRoutine(hr.ctlr)
|
||||
|
||||
// run watcher
|
||||
go func() {
|
||||
defer hr.watcher.Close()
|
||||
|
||||
@@ -69,6 +69,8 @@ func newServeCmd(conf *config.Config) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
initShutDownRoutine(ctlr)
|
||||
|
||||
if err := ctlr.Run(); err != nil {
|
||||
log.Error().Err(err).Msg("failed to start controller, exiting")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user