forego
forego copied to clipboard
Forego adds sleeping bash process for every application (read from .profile)
While examining processes and thread on our Docker-hosts, I found:
root 32287 32216 0 Sep07 ? 00:01:01 forego start -r -f /root/Procfile
root 32293 32287 0 Sep07 ? 00:00:00 /bin/bash -c source "/root/.profile" 2>/dev/null; nginx -g 'daemon off;'
root 32297 32287 0 Sep07 ? 00:00:00 /bin/bash -c source "/root/.profile" 2>/dev/null; docker-run.sh
root 32300 32287 0 Sep07 ? 00:00:00 /bin/bash -c source "/root/.profile" 2>/dev/null; crond -f
root 32303 32287 0 Sep07 ? 00:00:00 /bin/bash -c source „/root/.profile“ 2>/dev/null; yii resque/work internal
Should be coming from https://github.com/ddollar/forego/blob/c6e54eeee78456219f9aa6dcf9d5ed65d671b37e/unix.go#L13-L22, I think.
Couldn't this be optimized, so we don't have those sleeping processes?
There are also the processes themselves:
root 32299 32293 0 Sep07 ? 00:00:00 nginx: master process nginx -g daemon off;
root 32305 32300 0 Sep07 ? 00:00:53 crond -f
root 32307 32303 0 Sep07 ? 00:02:39 php /app/yii resque/work internal
root 32304 32297 0 Sep07 ? 00:00:00 /bin/bash /usr/local/bin/docker-run.sh
forego execs the command now, so this issue can be closed, I think.
Additionally, there appears to be an issue with sending signals to the child process. (Related to #114?)
When I have the following Procfile
apache2: source /etc/apache2/envvars; apache2 -DNO_DETACH
cron: cron -f
I see the following
# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 02:49 ? 00:00:00 /bin/bash
root 17 0 0 02:49 ? 00:00:00 /bin/bash
root 226 1 0 02:59 ? 00:00:00 forego start -r -f /Procfile
root 240 226 0 02:59 ? 00:00:00 /bin/bash -c source "/.profile" 2>/dev/null; source /etc/apache2/envvars; apache2 -DNO_
root 242 226 0 02:59 ? 00:00:00 /bin/bash -c source "/.profile" 2>/dev/null; cron -f
root 243 240 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
root 244 242 0 02:59 ? 00:00:00 cron -f
docker 248 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 249 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 250 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 251 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 252 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
root 259 17 0 02:59 ? 00:00:00 ps -ef
If I send SIGINT to forego (by issuing Ctrl+C):
^C | ctrl-c detected
forego | sending SIGTERM to cron.1
forego | sending SIGTERM to apache2.1
I see the /bin/bash processes exit (and cron), but not apache2:
# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 02:49 ? 00:00:00 /bin/bash
root 17 0 0 02:49 ? 00:00:00 /bin/bash
root 243 1 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 248 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 249 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 250 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 251 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
docker 252 243 0 02:59 ? 00:00:00 apache2 -DNO_DETACH
root 260 17 0 03:01 ? 00:00:00 ps -ef