From 7649488a268f74c21524ab440411eac0a35b26e2 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Thu, 9 Aug 2018 05:04:49 -0400 Subject: 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. --- cmd/mattermost/commands/jobserver.go | 9 ++++----- cmd/mattermost/commands/server.go | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/mattermost/commands/jobserver.go b/cmd/mattermost/commands/jobserver.go index 43a21d61f..253ada932 100644 --- a/cmd/mattermost/commands/jobserver.go +++ b/cmd/mattermost/commands/jobserver.go @@ -41,11 +41,15 @@ func jobserverCmdF(command *cobra.Command, args []string) { // Run jobs mlog.Info("Starting Mattermost job server") + defer mlog.Info("Stopped Mattermost job server") + if !noJobs { a.Jobs.StartWorkers() + defer a.Jobs.StopWorkers() } if !noSchedule { a.Jobs.StartSchedulers() + defer a.Jobs.StopSchedulers() } signalChan := make(chan os.Signal, 1) @@ -54,9 +58,4 @@ func jobserverCmdF(command *cobra.Command, args []string) { // Cleanup anything that isn't handled by a defer statement mlog.Info("Stopping Mattermost job server") - - a.Jobs.StopSchedulers() - a.Jobs.StopWorkers() - - mlog.Info("Stopped Mattermost job server") } diff --git a/cmd/mattermost/commands/server.go b/cmd/mattermost/commands/server.go index 1c33505f5..0b7ef009c 100644 --- a/cmd/mattermost/commands/server.go +++ b/cmd/mattermost/commands/server.go @@ -181,9 +181,11 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform if *a.Config().JobSettings.RunJobs { a.Jobs.StartWorkers() + defer a.Jobs.StopWorkers() } if *a.Config().JobSettings.RunScheduler { a.Jobs.StartSchedulers() + defer a.Jobs.StopSchedulers() } notifyReady() @@ -201,9 +203,6 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform a.Metrics.StopServer() } - a.Jobs.StopSchedulers() - a.Jobs.StopWorkers() - return nil } -- cgit v1.2.3-1-g7c22