4

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.

2 Answers 2

7

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.

2
  • 1
    Correct! A quick note for any EC2 folks, use the "Private IP" listed on your account if your workers are on EC2 as well. Public IP didn't seem to work.
    – Phil Sturgeon
    Jan 14, 2012 at 0:40
  • Good to know that. I really didn't like the idea of making the daemon publicly available.
    – tishma
    Mar 17, 2013 at 17:06
2

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.

2
  • They are all on different instances so they have a host name in the first parameter.
    – Phil Sturgeon
    Jan 13, 2012 at 19:31
  • When I left the field blank (default), it couldn't connect locally. I specified 127.0.0.1 everywhere and then it worked locally.
    – Daniel W.
    Apr 12, 2016 at 12:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .