Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Heroku background workers?

I'm using Heroku running a PHP app, I need to setup background workers which talk to external APIs and write to my DB, Heroku has lots of info about setting up workers for Ruby but not for PHP.

Is this easily doable on Heroku with PHP?

I've never tackled launching background processes and I can't seem to find any docs detailing it...

like image 859
cal Avatar asked May 16 '12 08:05

cal


People also ask

Does Heroku supports PHP?

Heroku allows you to run your application using the official PHP runtime.

What is heroku worker?

Worker: Worker dynos can be of any process type declared in your Procfile, other than “web”. Worker dynos are typically used for background jobs, queueing systems, and timed jobs. You can have multiple kinds of worker dynos in your application. For example, one for urgent jobs and another for long-running jobs.

How do I stop heroku dyno?

Stopping one-off dynos If you wish to stop a running one-off dyno, use heroku ps:stop with its name. A one-off dyno will not stop if you issue heroku ps:restart on your application.


1 Answers

Add the following environment variables:

# Add this config
$ heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib

Then you can just add the worker to your Procfile.

worker: cd ~/www/ && ~/php/bin/php worker.php
like image 80
anthonyfojas Avatar answered Oct 14 '22 15:10

anthonyfojas