See #32
gotenv can read simple yaml file so we don't need to use a read yaml
parse.
The value in forego file will be set as default value, if we set flag
or env value, it will override the value in forego file
* Remove unnecessary return
* Simplify method Forego.startProcess
We need to call f.teardown.Fall() only when a process has finished
and restart is disabled.
When f.teardown.Barrier() is closed, it’s unnecessary to call
f.teardown.Fall() because we know the barrier is already closed.
* Don’t wait twice on finished
The select has two cases. In the first case, we wait on finished.
We don’t need to wait on finished a second time since we already know
that finished is closed. This is the reason why we moved the defer statement
at the beginning of the second case.
* This goroutine doesn’t need to block until the process has finished
Read the `PORT` from the system environment if it's present. This is
related to #44 and will make the port read order this:
1. `-p` flag.
2. `PORT` in the `.env` file
3. `PORT` environment variable
4. 5000 as default port
This doesn't usually happen unless the shell is broken or unavailable.
It's nice though to have a program which shows an error message rather
than quitting silently. The test to see if this is working is to modify
the shell in `unix.go` to something which doesn't exist.
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.
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.