I\'m using Ubuntu Natty with PHP 5.3.8. I just got Gearman working on my server.
I did a few tests with some scripts I got off the PHP Manual, and everything works o
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-setuptools
easy_install supervisor
echo_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/supervisord
update-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.php
numprocs=1
directory=/root/gearman
stdout_logfile=/root/gearman/supervisord.log
environment=GEARMAN_USER=gearman
autostart=true
autorestart=true
user=gearman
stopsignal=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.
Another option is to use screen to put the worker task into a detached shell:
screen -d -m php worker.php
For background workers you can use GearmanManager by Brian Moon https://github.com/brianlmoon/GearmanManager