diff --git a/hivemind.go b/hivemind.go index d5a97f5..d076c80 100644 --- a/hivemind.go +++ b/hivemind.go @@ -37,7 +37,7 @@ func newHivemind(conf hivemindConfig) (h *hivemind) { for i, entry := range entries { if len(procNames) == 0 || stringsContain(procNames, entry.Name) { - h.procs = append(h.procs, newProcess(entry.Name, entry.Command, baseColor+i, conf.Root, h.output)) + h.procs = append(h.procs, newProcess(entry.Name, entry.Command, baseColor+i, conf.Root, entry.Port, h.output)) } } diff --git a/process.go b/process.go index 365bde3..595fc68 100644 --- a/process.go +++ b/process.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "os/exec" "syscall" @@ -15,7 +16,7 @@ type process struct { output *multiOutput } -func newProcess(name, command string, color int, root string, output *multiOutput) (proc *process) { +func newProcess(name, command string, color int, root string, port int, output *multiOutput) (proc *process) { proc = &process{ exec.Command("/bin/sh", "-c", command), name, @@ -24,6 +25,7 @@ func newProcess(name, command string, color int, root string, output *multiOutpu } proc.Dir = root + proc.Env = append(os.Environ(), fmt.Sprintf("PORT=%d", port)) proc.output.Connect(proc) diff --git a/procfile.go b/procfile.go index 6de8655..48021d7 100644 --- a/procfile.go +++ b/procfile.go @@ -4,13 +4,12 @@ import ( "bufio" "os" "regexp" - "strconv" - "strings" ) type procfileEntry struct { Name string Command string + Port int } func parseProcfile(path string, portBase, portStep int) (entries []procfileEntry) { @@ -40,10 +39,7 @@ func parseProcfile(path string, portBase, portStep int) (entries []procfileEntry } names[name] = true - entries = append(entries, procfileEntry{ - name, - strings.Replace(cmd, "$PORT", strconv.Itoa(port), -1), - }) + entries = append(entries, procfileEntry{name, cmd, port}) port += portStep }