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

Add an --ontop arg to keep the process alive for heroku #725

Closed
wants to merge 4 commits into from

Conversation

joshco
Copy link

@joshco joshco commented Oct 8, 2014

when using daemonized DJ workers, heroku needs the parent process to stay alive. Otherwise, when it exits, the dyno will terminate, killing the workers.
This change adds --ontop to the command line options. It passed the :ontop parameter to the Daemonize call when set.

@dgobaud
Relates to issue #565 #615

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.17%) when pulling ca3f604 on joshco:master into c85a4fe on collectiveidea:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.17%) when pulling f92dde4 on joshco:master into c85a4fe on collectiveidea:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.17%) when pulling f92dde4 on joshco:master into c85a4fe on collectiveidea:master.

@sferik sferik force-pushed the master branch 2 times, most recently from 00c7e65 to 27ce6b0 Compare October 8, 2014 16:38
@albus522
Copy link
Member

albus522 commented Oct 9, 2014

--ontop is the same as using run instead of start. -n N will not work the way you think it will. Instead of forking the specified number of workers, 1 worker will run and every time SIGINT occurs the worker will reset, not restart, and start working again until N SIGINT's have been received then it will finally exit.

@albus522 albus522 closed this Oct 9, 2014
@joshco
Copy link
Author

joshco commented Oct 22, 2014

You are correct. It behaves exactly as you describe. I guess what I'd need to do is only 'ontop' the last worker to be started to keep the whole thing from going away in heroku.
Do you have any recommendation for using this on heroku?

@joshco
Copy link
Author

joshco commented Oct 22, 2014

Right now what I'm doing is using the standard issue delayed_job with this script on heroku
basically spawn n-1 background jobs then run the last one in the foreground.
The only glitch is that I lose stdout logging from the background jobs.
I can get by with what DJ web shows me.

#!/usr/bin/env bash

COUNT=`expr $DJ_DAEMONS - 1`
# dj spawner
echo "Total: $DJ_DAEMONS Starting $COUNT jobs"
bundle exec bin/delayed_job --queue=matching -n $COUNT start
echo "starting parent"
QUEUE=matching bundle exec rake jobs:work

@albus522
Copy link
Member

This #615 is in the works, but I haven't had the chance to polish the rough edges

@dgobaud
Copy link

dgobaud commented Oct 22, 2014

Loss of logging is why I went with the solution in #615. I think I tried to fix logging by redirecting stdout/stderr etc from the child processes to the parent but I couldn't get it to work and don't remember why.

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

Successfully merging this pull request may close these issues.

4 participants