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...
Heroku allows you to run your application using the official PHP runtime.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With