Skip to content

Instantly share code, notes, and snippets.

@Sitebase
Created November 13, 2012 13:03
Show Gist options
  • Save Sitebase/4065664 to your computer and use it in GitHub Desktop.
Save Sitebase/4065664 to your computer and use it in GitHub Desktop.
PHP Worker file that restarts after crash
worker: while true; do cd /app/www/ && /app/bin/php worker.php; sleep 1; done
<?php
while (true) {
echo 'Hello world at ' . time() . PHP_EOL;
sleep(1);
}
@Sitebase
Copy link
Author

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.

@Sitebase
Copy link
Author

Sitebase commented Apr 9, 2013

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.

@victorbstan
Copy link

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