I have Gearman installed, running and passing jobs around perfectly fine but only when I manually start up the job queue with this command:
/usr/sbin/gearmand -p 4730 -vvvv -u gearman
If I do this I have another EC2 instance running as a worker and a third passing in jobs. Perfect, but I don't want to have to keep a terminal open (obviously) or mess around with screen. I'd like this to run on startup.
So:
$ ps aux | grep gearman
gearman 745 0.2 0.2 8096 1388 ? Ss 19:11 0:00 /usr/sbin/gearmand --pid-file=/var/run/gearman/gearmand.pid --user=gearman --daemon --log-file=/var/log/gearman-job-server/gearman.log --listen=127.0.0.1
Looks good to me. But when I tell my worker to connect:
$ php workers/resize.php
Waiting for job...
PHP Warning: GearmanWorker::work(): gearman_connection_flush:write:111 in /home/ubuntu/workers/resize.php on line 20
Fail!
Also I have noticed nothing is going into the log file (it was not created automatically, but was referenced in this init.d script on install). I tried creating it and even chowning to gearman:gearman but no joy there, so it's tough to debug.
The problem is that the daemon is listening on 127.0.0.1/local loopback rather than a public IP.
This is specified in /etc/default/gearman-job-server on Ubuntu.
Change it to the public IP of the machine, restart the daemon with the init script and all should be well.
Typically this error happens due to a parameter in GearmanClient::addServer(). It doesn't like "localhost" as a parameter. Try specifying 127.0.0.1 or specifying nothing.