Last Updated: February 25, 2016
·
2.321K
· sitebase

Heroku PHP Worker

With the following code you can have a PHP worker on Heroku that auto restarts after a crash:

worker.php file

<?php
while (true) {
echo 'Hello world at ' . time() . PHP_EOL;
sleep(1);
}

Procfile

worker: while true; do cd /app/www/ && /app/bin/php worker.php; sleep 1; done

I've also created a gist for this: https://gist.github.com/Sitebase/4065664

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside