Skip to content

Commit a257140

Browse files
mpfz0rMarius Sturm
authored and
Marius Sturm
committed
Handle backend changes (#323)
* 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
1 parent d1179f9 commit a257140

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

daemon/daemon.go

+15
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,23 @@ func (dc *DaemonConfig) SyncWithAssignments(configChecksums map[string]string, c
119119
runnerBackend := runner.GetBackend()
120120
if backend != nil && !runnerBackend.EqualSettings(backend) {
121121
log.Infof("[%s] Updating process configuration", runner.Name())
122+
runnerServiceType := runnerBackend.ServiceType
122123
runner.SetBackend(*backend)
123124
configChecksums[backend.Id] = ""
125+
if backend.ServiceType != runnerServiceType {
126+
log.Infof("Changing process runner (%s -> %s) for: %s",
127+
runnerServiceType, backend.ServiceType, backend.Name)
128+
dc.DeleteRunner(id)
129+
dc.AddRunner(*backend, context)
130+
}
131+
// XXX
132+
// We should, but cannot trigger a restart here.
133+
//
134+
// If a backend gets renamed, it expects the configuration under a new path.
135+
// Therefore, we don't copy the configuration from the old backend to the new backend,
136+
// but keep it empty.
137+
// This will trigger `services.checkForUpdateAndRestart()` to write a new
138+
// configuration and then restart the runner.
124139
}
125140

126141
// cleanup backends that should not run anymore

daemon/exec_runner.go

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ func (r *ExecRunner) GetBackend() *backends.Backend {
109109
func (r *ExecRunner) SetBackend(b backends.Backend) {
110110
r.backend = b
111111
r.name = b.Name
112+
r.stderr = filepath.Join(r.context.UserConfig.LogPath, b.Name+"_stderr.log")
113+
r.stdout = filepath.Join(r.context.UserConfig.LogPath, b.Name+"_stdout.log")
112114
r.exec = b.ExecutablePath
113115
r.args = b.ExecuteParameters
114116
r.restartCount = 1

0 commit comments

Comments
 (0)