A process runs its own bundle's binary, written ./name (hq ADR 0193)
A bundle compiled to a binary runs itself, but only the host knows where it unpacked it, and the service manager takes no path relative to the working directory. A command written ./name is that file in the process's own unpacked bundle, made absolute in the unit.
This commit is contained in:
@@ -313,3 +313,16 @@ func TestAProcessAppliedAgainIsUnchangedAndNotRestarted(t *testing.T) {
|
||||
t.Errorf("third apply: %+v, want unchanged", o)
|
||||
}
|
||||
}
|
||||
|
||||
// novox/hq ADR 0193: a bundle compiled to a binary runs itself — `./name` is that file in the
|
||||
// process's own unpacked bundle, made absolute because the service manager takes nothing relative.
|
||||
func TestAProcessRunsItsOwnBundlesBinary(t *testing.T) {
|
||||
unit := unitFor(&declaration.Process{Name: "node-tools", Run: []string{"./node-tools", "serve"}})
|
||||
if !strings.Contains(unit, "ExecStart="+filepath.Join(daemonRoot, "node-tools", "node-tools")+" serve\n") {
|
||||
t.Errorf("the binary is not run from its bundle:\n%s", unit)
|
||||
}
|
||||
other := unitFor(&declaration.Process{Name: "x", Run: []string{"node", "src/main.js"}})
|
||||
if !strings.Contains(other, "ExecStart=node src/main.js\n") {
|
||||
t.Errorf("a command found on the path was changed:\n%s", other)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user