andris9 / node-gearman Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
var Gearman = require("../lib/gearman"),
gearman = new Gearman(); // defaults to localhost
gearman.registerWorker("reverse", function(payload, worker){
workerFunc(payload);
function workerFunc(payload)
{
if(somthing error){
worker.error();
return;
}
}
});
when worker.error() is do, the payload will be delete from the reverse, but I want another worker to do the payload.
how to do?
I pass stringified objects to all of my workers. Those workers then parse the payload, do their thing, then return their result as a stringified object, which the recipient then parses.
This works great, when submitting a standard job. I'm encountering a mysterious issue when running background jobs, though (see above example).
For a foreground job, the incoming worker payload looks like this:
Incoming doSomething job <Buffer 7b 22 61 6e 69 6d 61 6c 73 22 3a 5b 22 63 61 74 73 22 2c 22 64 6f 67 73 22 5d 7d>
For a background job, the incoming worker payload looks like this:
Incoming doSomething job <Buffer 7b 22 61 6e 69 6d 61 6c 73 22 3a 5b 22 63 61 74 73 22 2c 22 64 6f 67 73 22 5d 7d 00>
Note the extra 00
on the tail end there. This is causing my JSON to fail to be parsed, even though it looks identical. Any idea what's going on here?
For example, this coffeescript code
NodeGearman = require 'node-gearman'
gearman = new NodeGearman 'localhost', 4730
for i in [1..5]
gearman.registerWorker "test", (payload, worker) =>
setTimeout =>
worker.end()
, 5000
should make 5 workers instead of one, making the queue processed at a rate of 1 task per second. Instead only 1 worker gets created.
How I should handle WORK_EXCEPTION? Problem:
var job = gearman.submitJob("someworker", data);
job.on("error", function(error) {
// this doesn't work when WORK_EXCEPTION is returned by worker
// works well when worker return WORK_FAIL
});
Hello everybody!
I want to be able to start / stop multiple background jobs from a webpage using node.js. However I can't seem to find a way to get the handle to identify the job:
receiveHandle only returns "invalid response from server"
However, when I switch on Debug-Mode in the worker and job the handle is clearly visible in the output.
How can I read the handle to pass it to the webpage after job creation, so I can see which job is running?
Thank you very much in advance!
Markus
If worker through haproxy proxy to request gearman, worker will work for few minitues, and then droped,
do not know how to solve?
Is this repository still being updated?
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");
Hi Andris,
Was wondering if you could help me here:
If I run the worker.js in the examples, and I let the script idle for a certain amount of time (overnight)...then the next morning when I submit a job, the worker doesn't get it. It's like it timed-out the connection or something?
I have to restart worker.js, and it seems to work again.
Thanks!
Felix
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.