Created
November 13, 2012 13:03
-
-
Save Sitebase/4065664 to your computer and use it in GitHub Desktop.
PHP Worker file that restarts after crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker: while true; do cd /app/www/ && /app/bin/php worker.php; sleep 1; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
while (true) { | |
echo 'Hello world at ' . time() . PHP_EOL; | |
sleep(1); | |
} |
Make sure if you use this on Heroku to add:
-d apc.enabled=0
to disable apc in the worker otherwise you'll get some serious caching problems.
For heroku to automatically detect this as a PHP project for it's build-pack, you also need a composer.json
file, even if it's empty (contains {}
).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be a good idea to add a logger before the sleep so that you can see in your logs if your worker crashes or not. This way you know that you have some fatal error or something in your PHP worker.