Skip to content

Commit

Permalink
Fix accidentally stateful port calculation ddollar#105 ddollar#105
Browse files Browse the repository at this point in the history
  • Loading branch information
bugficks committed Jul 15, 2020
1 parent 483193b commit 2e5a838
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
## forego
+ https://github.com/ddollar/forego/pull/105
+ https://github.com/ddollar/forego/pull/124

<a href="https://circleci.com/gh/ddollar/forego">
<img align="right" src="https://circleci.com/gh/ddollar/forego.svg?style=svg">
<a href="https://circleci.com/gh/bugficks/forego">
<img align="right" src="https://circleci.com/gh/bugficks/forego.svg?style=svg">
</a>

[Foreman](https://github.com/ddollar/foreman) in Go.

### Installation

[Downloads](https://dl.equinox.io/ddollar/forego/stable)
[Downloads](https://github.com/bugficks/forego/releases)

##### Compile from Source

$ go get -u github.com/ddollar/forego
$ go get -u github.com/bugficks/forego

### Usage

Expand Down
15 changes: 7 additions & 8 deletions start.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,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(basePort, idx, procNum int, proc ProcfileEntry, env Env, of *OutletFactory) {

port = port + (idx * 100)
port := basePort + (idx * 100)

const interactive = false
workDir := filepath.Dir(flagProcfile)
Expand Down Expand Up @@ -240,7 +236,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(basePort, idx, procNum, proc, env, of)
} else {
f.teardown.Fall()
}
Expand Down Expand Up @@ -278,6 +274,9 @@ func runStart(cmd *Command, args []string) {
env, err := loadEnvs(envs)
handleError(err)

basePort, err := basePort(env)
handleError(err)

of := NewOutletFactory()
of.LeftFormatter = fmt.Sprintf("%%-%ds | ", pf.LongestProcessName(concurrency))

Expand Down Expand Up @@ -325,7 +324,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(basePort, idx, i, proc, env, of)
}
}
}
Expand Down

0 comments on commit 2e5a838

Please sign in to comment.