Commit 7649488a authored by Jesse Hallam's avatar Jesse Hallam Committed by Carlos Tadeu Panato Junior

MM-11637: avoid stopping unstarted jobs (#9240)

The new locking primitives in 5.2 around jobs assume the
worker/scheduler was actually started, so don't try to stop if not
started.
parent 5fbec91c
...@@ -41,11 +41,15 @@ func jobserverCmdF(command *cobra.Command, args []string) { ...@@ -41,11 +41,15 @@ func jobserverCmdF(command *cobra.Command, args []string) {
// Run jobs // Run jobs
mlog.Info("Starting Mattermost job server") mlog.Info("Starting Mattermost job server")
defer mlog.Info("Stopped Mattermost job server")
if !noJobs { if !noJobs {
a.Jobs.StartWorkers() a.Jobs.StartWorkers()
defer a.Jobs.StopWorkers()
} }
if !noSchedule { if !noSchedule {
a.Jobs.StartSchedulers() a.Jobs.StartSchedulers()
defer a.Jobs.StopSchedulers()
} }
signalChan := make(chan os.Signal, 1) signalChan := make(chan os.Signal, 1)
...@@ -54,9 +58,4 @@ func jobserverCmdF(command *cobra.Command, args []string) { ...@@ -54,9 +58,4 @@ func jobserverCmdF(command *cobra.Command, args []string) {
// Cleanup anything that isn't handled by a defer statement // Cleanup anything that isn't handled by a defer statement
mlog.Info("Stopping Mattermost job server") mlog.Info("Stopping Mattermost job server")
a.Jobs.StopSchedulers()
a.Jobs.StopWorkers()
mlog.Info("Stopped Mattermost job server")
} }
...@@ -181,9 +181,11 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform ...@@ -181,9 +181,11 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform
if *a.Config().JobSettings.RunJobs { if *a.Config().JobSettings.RunJobs {
a.Jobs.StartWorkers() a.Jobs.StartWorkers()
defer a.Jobs.StopWorkers()
} }
if *a.Config().JobSettings.RunScheduler { if *a.Config().JobSettings.RunScheduler {
a.Jobs.StartSchedulers() a.Jobs.StartSchedulers()
defer a.Jobs.StopSchedulers()
} }
notifyReady() notifyReady()
...@@ -201,9 +203,6 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform ...@@ -201,9 +203,6 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform
a.Metrics.StopServer() a.Metrics.StopServer()
} }
a.Jobs.StopSchedulers()
a.Jobs.StopWorkers()
return nil return nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment