Skip to content
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
5 changes: 3 additions & 2 deletions webcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,13 @@ func webAutostart(cfgPath, addr string) *web.Autostart {
if abs, err := filepath.Abs(exe); err == nil {
exe = abs
}
argv := []string{exe, "web", "-no-open", "-addr", addr}
argv := []string{exe}
if cfgPath != "" {
if abs, err := filepath.Abs(cfgPath); err == nil {
argv = append(argv, "-config", abs)
argv = append(argv, "-config", abs) // a global flag: before the command
}
}
argv = append(argv, "web", "-no-open", "-addr", addr)
return &web.Autostart{Sys: autostart.Default(), Argv: argv, Path: os.Getenv("PATH")}
}

Expand Down
9 changes: 7 additions & 2 deletions webcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,17 @@ func TestRunningWeb(t *testing.T) {
}
}

// TestWebAutostartArgv: the same address and an absolute -config.
// TestWebAutostartArgv: the same address and an absolute -config, which is
// a global flag: after web, the web command rejects it and the service
// never starts.
func TestWebAutostartArgv(t *testing.T) {
a := webAutostart("c.yaml", "127.0.0.1:9000")
if a == nil || len(a.Argv) != 7 || !filepath.IsAbs(a.Argv[0]) || strings.Join(a.Argv[1:5], " ") != "web -no-open -addr 127.0.0.1:9000" || !filepath.IsAbs(a.Argv[6]) {
if a == nil || len(a.Argv) != 7 || !filepath.IsAbs(a.Argv[0]) || a.Argv[1] != "-config" || !filepath.IsAbs(a.Argv[2]) || strings.Join(a.Argv[3:], " ") != "web -no-open -addr 127.0.0.1:9000" {
t.Errorf("argv = %+v", a)
}
if a := webAutostart("", "127.0.0.1:9000"); a == nil || strings.Join(a.Argv[1:], " ") != "web -no-open -addr 127.0.0.1:9000" {
t.Errorf("argv without -config = %+v", a)
}
}

// TestWebSetupLaneway: on a laneway-server the setup screen starts a
Expand Down
Loading