Skip to content

Commit

Permalink
Handle backend changes (#323)
Browse files Browse the repository at this point in the history
* Handle a backend ServiceType change

If the service type changes, switch the backend to a new runner.

* Update stderr and stdout log files on backend rename
  • Loading branch information
mpfz0r authored and Marius Sturm committed Jan 4, 2019
1 parent d1179f9 commit a257140
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions daemon/exec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a257140

Please sign in to comment.