Running Gearman Workers in the Background
Ok. I found a solution to my earlier problem. It involves using Supervisord to deamonize the gearman worker(s).
Here's how to install Supervisord
apt-get install python-setuptoolseasy_install supervisorecho_supervisord_conf > /etc/supervisord.conf
Here's how to configure it (first get an init script from here and save it to /etc/init.d/supervisord
), then do the following:
chmod +x /etc/init.d/supervisordupdate-rc.d -f supervisord defaults
You then need to update your supervisor.conf file to tell supervisord which command you want to run as a daemon (of course, this would be your gearman worker). Below is just a sample of what you would add to your supervisord.conf file, you'll need to update it to your own specific situation.
[program:gearman]command=/usr/bin/php php_gearman_worker.phpnumprocs=1directory=/root/gearmanstdout_logfile=/root/gearman/supervisord.logenvironment=GEARMAN_USER=gearmanautostart=trueautorestart=trueuser=gearmanstopsignal=KILL
When you're done, then start supervisord i.e. /etc/init.d/supervisord start
.
Once you do this, your Gearman worker is now active and you can now run your gearman client via the command line or with your browser.
I hope this helps.
For background workers you can use GearmanManager by Brian Moonhttps://github.com/brianlmoon/GearmanManager