From b7c9ff12c70ae1f2f59598bf12c4b9db6ffd3fa9 Mon Sep 17 00:00:00 2001 From: Brandon Bloom Date: Thu, 22 Jun 2017 10:23:39 -0700 Subject: [PATCH] Fix accidentally stateful port calculation. Before: forego | starting aaa.1 on port 5000 forego | starting bbb.1 on port 5100 forego | starting ccc.1 on port 5300 forego | starting ddd.1 on port 5600 forego | starting eee.1 on port 6000 After: forego | starting aaa.1 on port 5000 forego | starting bbb.1 on port 5100 forego | starting ccc.1 on port 5200 forego | starting ddd.1 on port 5300 forego | starting eee.1 on port 5400 --- start.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/start.go b/start.go index 59f5e47..cf4d6a5 100644 --- a/start.go +++ b/start.go @@ -180,13 +180,9 @@ func basePort(env Env) (int, error) { return defaultPort, nil } -func (f *Forego) startProcess(idx, procNum int, proc ProcfileEntry, env Env, of *OutletFactory) { - port, err := basePort(env) - if err != nil { - panic(err) - } +func (f *Forego) startProcess(base, idx, procNum int, proc ProcfileEntry, env Env, of *OutletFactory) { - port = port + (idx * 100) + port := base + (idx * 100) const interactive = false workDir := filepath.Dir(flagProcfile) @@ -236,7 +232,7 @@ func (f *Forego) startProcess(idx, procNum int, proc ProcfileEntry, env Env, of select { case <-finished: if flagRestart { - f.startProcess(idx, procNum, proc, env, of) + f.startProcess(base, idx, procNum, proc, env, of) } else { f.teardown.Fall() } @@ -274,6 +270,9 @@ func runStart(cmd *Command, args []string) { env, err := loadEnvs(envs) handleError(err) + base, err := basePort(env) + handleError(err) + of := NewOutletFactory() of.Padding = pf.LongestProcessName(concurrency) @@ -321,7 +320,7 @@ func runStart(cmd *Command, args []string) { } for i := 0; i < numProcs; i++ { if (singleton == "") || (singleton == proc.Name) { - f.startProcess(idx, i, proc, env, of) + f.startProcess(base, idx, i, proc, env, of) } } }