Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forego adds sleeping bash process for every application (read from .profile) #106

Open
schmunk42 opened this issue Oct 2, 2017 · 2 comments

Comments

@schmunk42
Copy link

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

forego/unix.go

Lines 13 to 22 in c6e54ee

func ShellInvocationCommand(interactive bool, root, command string) []string {
shellArgument := "-c"
if interactive {
shellArgument = "-ic"
}
profile := filepath.Join(root, ".profile")
shellCommand := fmt.Sprintf("source \"%s\" 2>/dev/null; %s", profile, command)
return []string{"bash", shellArgument, shellCommand}
}
, 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
@flori
Copy link

flori commented Jan 31, 2018

forego execs the command now, so this issue can be closed, I think.

@JonathonReinhart
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants