From 4547fcd4d8cef3204715a6c00cea7d600e522827 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Thu, 3 Jan 2019 10:48:31 +0100 Subject: [PATCH 1/2] Handle a backend ServiceType change If the service type changes, switch the backend to a new runner. --- daemon/daemon.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/daemon/daemon.go b/daemon/daemon.go index 471d52e..f786385 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -119,8 +119,23 @@ func (dc *DaemonConfig) SyncWithAssignments(configChecksums map[string]string, c runnerBackend := runner.GetBackend() if backend != nil && !runnerBackend.EqualSettings(backend) { log.Infof("[%s] Updating process configuration", runner.Name()) + runnerServiceType := runnerBackend.ServiceType runner.SetBackend(*backend) configChecksums[backend.Id] = "" + if backend.ServiceType != runnerServiceType { + log.Infof("Changing process runner (%s -> %s) for: %s", + runnerServiceType, backend.ServiceType, backend.Name) + dc.DeleteRunner(id) + dc.AddRunner(*backend, context) + } + // XXX + // We should, but cannot trigger a restart here. + // + // If a backend gets renamed, it expects the configuration under a new path. + // Therefore, we don't copy the configuration from the old backend to the new backend, + // but keep it empty. + // This will trigger `services.checkForUpdateAndRestart()` to write a new + // configuration and then restart the runner. } // cleanup backends that should not run anymore From 567316801410e96f7841ceb8cbb5eae50cd68850 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Fri, 4 Jan 2019 11:28:49 +0100 Subject: [PATCH 2/2] Update stderr and stdout log files on backend rename --- daemon/exec_runner.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/daemon/exec_runner.go b/daemon/exec_runner.go index e0a57a8..3ff3bb4 100644 --- a/daemon/exec_runner.go +++ b/daemon/exec_runner.go @@ -109,6 +109,8 @@ func (r *ExecRunner) GetBackend() *backends.Backend { func (r *ExecRunner) SetBackend(b backends.Backend) { r.backend = b r.name = b.Name + r.stderr = filepath.Join(r.context.UserConfig.LogPath, b.Name+"_stderr.log") + r.stdout = filepath.Join(r.context.UserConfig.LogPath, b.Name+"_stdout.log") r.exec = b.ExecutablePath r.args = b.ExecuteParameters r.restartCount = 1