This is done because I want to make the *exec.Command shim narrower so
that we can transition to another method for reading Stdout/Stderr to
fix the newline bug described in #16.
Now that the process which starts things is responsible for killing
them, it's no longer possible for the *Process to be nil, so the check
is unnecessary and there is no platform difference, so it's moved to
process.go.
This is a large change which makes startProcess() responsible for
shutting its own process down, rather than having a global map.
This makes it much easier to reason about who owns what and get the
synchronization right.
The main immediate bugfix is that now we only attempt to send SIGKILL to
processes which haven't yet shut down, making it clearer which processes
are responsible for a delayed shutdown.
It introduces a `teardown` channel which is closed to signal to all
process-monitoring goroutines that they should clean up.
In addition, the platform-specific code has been thinned. Some of the
platform logic moved into the process-monitoring code because it needed
to for now after the introduction of the <-finished barrier.
This makes it so that the same goroutine responsible for starting
processes shuts them down. This is a stepping stone to a larger refactor
whose goal is to eliminate race conditions.
This serves two purposes. It protects with a Mutex where it was missing
before, and makes it so that there is only one place to change code for
the line writing, which will be a later pull request.
In the original foreman, an increase of 100 defined the number of the first process of the next group, hence, a two type Procfile uses ports 5000 and 5100. Forego was correctly printing this expected numbers but line 86 was recalculating this port number again with a distance of 1000 not a hundred. The result was that I was seeing my second type of process listening on port 6000, not the expected 5100.