Skip to content

Commit f5dcac5

Browse files
committed
fix: include PATH in systemd unit for callback child processes
1 parent 100610e commit f5dcac5

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

internal/cli/install.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ After=network-online.target
2323
[Service]
2424
Type=simple
2525
WorkingDirectory={{.WorkDir}}
26+
Environment=PATH={{.Path}}
2627
ExecStart={{.Binary}} daemon run --dir .comms
2728
Restart=on-failure
2829
RestartSec=5
@@ -162,7 +163,7 @@ func newInstallCmd() *cobra.Command {
162163
if err != nil {
163164
return err
164165
}
165-
err = unitTmpl.Execute(f, struct{ Name, WorkDir, Binary string }{svc, workDir, binary})
166+
err = unitTmpl.Execute(f, struct{ Name, WorkDir, Binary, Path string }{svc, workDir, binary, os.Getenv("PATH")})
166167
f.Close()
167168
if err != nil {
168169
return err

internal/cli/install_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func TestServiceName(t *testing.T) {
5454

5555
func TestUnitTemplateRendering(t *testing.T) {
5656
var buf bytes.Buffer
57-
err := unitTmpl.Execute(&buf, struct{ Name, WorkDir, Binary string }{
58-
"comms-stuart", "/home/user/p/stuart", "/usr/local/bin/comms",
57+
err := unitTmpl.Execute(&buf, struct{ Name, WorkDir, Binary, Path string }{
58+
"comms-stuart", "/home/user/p/stuart", "/usr/local/bin/comms", "/usr/local/bin:/usr/bin",
5959
})
6060
if err != nil {
6161
t.Fatalf("template execute: %v", err)

0 commit comments

Comments
 (0)