This is a better fix for several reasons:
- It's more portable; the arguments/options to 'ps' vary widely across
platforms.
- Killing children by forking yet more children (i.e., via backtick) is
problematic when you're trying to kill processes because of resource
starvation.
- Processes should not signal processes other than their own children,
especially in a generic task-runner like Foreman. If the signal
should propagate, then the sub-process should propagate signals to its
children itself. There's no way to know what cleanup or preparation
is necessary for a clean shutdown (e.g., SIGINT/SIGTERM), and
in what order grandchild processes should be shut down to properly
release locks, close files, etc.
- foreman-runner doesn't (shouldn't?) create grandchild processes; the
last thing it does is `exec` the program it's launching, which
will replace the program of the *current* process with the one
being started up.
http://0pointer.de/blog/projects/systemd.html
This adds support for exporting systemd targets and services. The
structure is based on the existing upstart support.
Quality is draft and expected to refine in the coming weeks.
One Foremanism that is not respected by these export templates is the
usual log output location, instead stdout and stderr go to syslog.
Since signals will no longer be handled once foreman goes into
`terminate_gracefully`, default signal handlers are restored so as
not to cause it to get stuck in an unTERMable state.
This necessitates not using the process group for signalling
except as a last resort, as foreman itself will receive the signals
it sends. This splits `killall` into two methods, one which
signals only processes foreman itself has started, and one which
signals all processes in the process group to try to clean up
more aggressively, and then reworks `terminate_gracefully` to use
them.
Some processes close their output channels and IO.select keeps
returning them as "readable", while IO#gets returns nil on them, thus
spending a lot of CPU looping through the same reader continuously
Foreman should be the process leader before killing processes using
his process group id.
Before that foreman was broken when it was not spawned from a shell.
This fixes the stdout code to ensure that empty lines are outputted.
Many times, these blank lines are intentional, so foreman should not
suppress them.
This fixes#286
It's better to not force the use of a package manager. Better to add it
to the global RUBYOPT if needed. Also, this fixes a dependency issue
when using the .deb package (rubygems1.9.1 is not required, and should
not be).