Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add muti job servers? #6

Open
askie opened this issue Jun 27, 2012 · 5 comments
Open

how to add muti job servers? #6

askie opened this issue Jun 27, 2012 · 5 comments

Comments

@askie
Copy link

askie commented Jun 27, 2012

I want to add 2 job servers as failover, how to do add 2 job servers? and how to register worker to muti job servers?

php have the method like this:

$gmclient= new GearmanClient();
$gmclient->addServers("10.0.0.1,10.0.0.2:7003");



$worker= new GearmanWorker(); 
$worker->addServers("10.0.0.1,10.0.0.2:7003");
@jockster
Copy link

Any news on this?

@andris9
Copy link
Owner

andris9 commented Sep 22, 2012

I've ceased using Gearman in favor of RabbitMQ and thus are not actively developing this module anymore, only making bug fixes etc.

@jockster
Copy link

Oh, I see.
Care to share your experiences on Gearman vs RabbitMQ?

@andris9
Copy link
Owner

andris9 commented Sep 22, 2012

Gearman is a fine product, it just turned out that most of the jobs that needed to be done were better handled asynchrounously in queues like provided by Rabbit. And as Rabbit can handle RPC-like calls also (although not as easy as with Gearman), there wasn't a reason to keep another dependency around.

@jockster
Copy link

Thanks for your input. I will check out rabbitmq!

I reckon that one could produce something like below to do even-distributed calls to a set of Gearman workers. I guess that keeping track of retries would be necessary before putting it into production:

Gearman = require("node-gearman")
workers = ["localhost", "localhost"]

sendJob = ->

  arglist = arguments

  worker = Math.floor(Math.random()*workers.length)
  gearman = new Gearman(workers[worker])
  job = gearman.submitJob.apply(gearman, arguments);

  job.setTimeout 3000

  gearman.on "connect", ->
    console.log "Connected to worker #" + worker + " @" + workers[worker]

  job.on "timeout", ->
    console.log "Timeout!"
    console.log "Retrying..."
    sendJob.apply(null, arglist); 
    gearman.close()

  job.on "error", (err) ->
    console.log "ERROR: ", err.message or err
    gearman.close()

  job.on "data", (reversed) ->
    console.log reversed.toString()

  job.on "end", ->
    console.log "Work finished"
    gearman.close()


sendJob("reverse", "test string")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants