Open stccorp opened 2 years ago
What language are your workers implemented in? C?
What version of gearmand are you using?
Does this happen using the gearman
command line tool to create a worker? For example: gearman -w -f wordcount wc &
?
This hasn't been my experience, but my workers are all implemented in Perl using this library. They don't die when gearmand is restarted and they automatically reconnect. I'm pretty sure that's true of PHP workers also.
Interesting, first time running gearman on the cli. Your were correct. if I run the worker and the kill gearman I get and infinate message gearman: gearman_worker_work : flush(GEARMAN_COULD_NOT_CONNECT) Connection to localhost:4730 failed -> libgearman/connection.cc:724: pid(10320)
And when I start gearmand again, the process still there. So it seems that the problem is the php client library(maybe)
I am using gearmand 1.1.19.1+ds -
if I run the reverse example from gearman.org. It dies as soon as I stop gearmand
I am using PHP
root@test1:~/test# php -f worker.php PHP Warning: GearmanWorker::work(): flush(GEARMAN_COULD_NOT_CONNECT) Connection to localhost:4730 failed -> libgearman/connection.cc:724: pid(10390) in /root/test/worker.php on line 8
I'm surprised to hear that PHP workers die when gearmand is stopped/killed. It might be a problem with the PHP Gearman library? Are you using https://github.com/php/pecl-networking-gearman/ ? Did you compile and install it yourself?
We have PHP Gearman clients at my job, but no workers are implemented in PHP, so I have no idea if this is expected behavior or not.
I am using Ubuntu. All I did to install gearman was sudo apt install gearman
I checked the sources list and it has this line
deb http://ppa.launchpad.net/ondrej/pkg-gearman/ubuntu bionic main
I did some googling, and I found some things that might help:
https://stackoverflow.com/questions/14749576/gearman-throws-gearman-could-not-connect-on-php-example https://stackoverflow.com/questions/22758869/gearman-workers-disconnect-periodicaly
The answer in that second link has a more complicated while
loop than in our example code. You might want to try some variation of that that outputs the value of $worker->returnCode()
. Maybe there's a return code that you can check for disconnects? This is all theoretical as I'm not a PHP programmer. (We don't maintain or distribute the PHP Gearman library. That's a separate project.)
Also, you might try asking on the Gearman mailing list: https://groups.google.com/g/gearman/
Thank you for the help. But nothing seems to work. What I am doing that other people do , is having a monitor so that when it dies, the monitor creates the workers again.
I will contact the gearman mailing list
Thank you
I would like to create a worker that if gearman server is not running, that the worker just try to reconnects in X amount of seconds.
The problem that I have is that if I have 10 workers listening and I restart the gearman server, all the workers die, instead of waiting for gearman server to comeback.
Thank you