Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle backend changes #323

Merged
merged 2 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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