Comments (9)
Having reconnect functionality after the beanstalkd server is gone away was also crucial for our infrastructure.
As we tried to implement a reconnect logic around fivebeans, we ran into multiple issues. One of them was that if we call worker.watch()
inside our worker.on('close')
callback function, fivebeans would also add the client listeners (on('connect')
, on('error')
, etc.) again, which of course would lead to an event emitter memory leak during the reconnection attempts.
Just calling worker.client.connect()
during the reconnection attempts fixed the listener issue. However after the beanstalkd server was up again, all new jobs added to the queue had a mysterious hang followed by a DEADLINE_SOON
after they were processed. At this point, the handler was already done, but it took a couple of seconds until the job was properly deleted.
So not sure if a reconnection behavior should be part of fivebeans, but one possible solution could be to write a simple wrapper which uses a separate connection to just check the availability of the beanstalkd server and reinitializes the worker if it was able to reconnect.
The following seems to work
const Beanworker = require('fivebeans').worker;
const Reconnect = require('net-socket-reconnect')
var beanHost = "127.0.0.1";
var beanPort = 11300;
var beanServer = Reconnect({
host: beanHost,
port: beanPort,
reconnectInterval: 5000
});
var worker, options = {
id: 'worker-test-01',
host: beanHost,
port: beanPort,
handlers: {
test: require('./handler/test')()
},
ignoreDefault: true
}
beanServer.on('connect', function () {
worker = new Beanworker(options);
worker.start(['test_tube']);
});
beanServer.on('close', function () {
if (worker) {
worker = null;
delete worker;
}
});
What do you think?
from fivebeans.
Or this is straightforward to roll by hand if necessary. Good bug.
from fivebeans.
I tried rolling it by hand, but I couldn’t get it working and then my brain hurt :)
Any pointers on how to approach this?
On 2 Jul 2014, at 18:18, C J Silverio [email protected] wrote:
Or this is straightforward to roll by hand if necessary. Good bug.
—
Reply to this email directly or view it on GitHub.
from fivebeans.
+1 I have rolled this by hand, and it makes the code a lot more confusing.
@ceejbot Do you have plans to add this to fivebeans, or is this something you'd prefer to see implimented in a wrapper library? If it's the later, I can throw something together no problem.
from fivebeans.
+1
need this behaviour as part of the library itself including reconnect and retry strategies
from fivebeans.
+1 I need this too
from fivebeans.
This thing has automatic reconnects and automatically re-uses / re-watches tubes on reconnect. It doesn't have anything advanced like an exponential backoff etc., but seems to work. Would be nice to get more mileage on it
from fivebeans.
Okay, this is pretty clearly something the module needs to do. Give me a little bit to reacquaint myself with what the heck I was thinking when I wrote it (my first node module ever, if you want to be scared) and make it reconnect. I like the server approach above.
from fivebeans.
@ceejbot did you reacquaint with your first baby? 😁 meanwhile our solution runs in production without any problems.
from fivebeans.
Related Issues (20)
- bug: if .connect() called more than once, incorrect callbacks are used HOT 1
- Obsolete documentation for yaml configuration HOT 3
- Release/Destroy fails to fire when using multiple Reserve in parallel HOT 4
- Is there a way to clear / destroy a queue?
- Connections left open
- Limit number of worker nodes.
- Security vulnerability
- Race condition
- Confused: Is Watch not allowed while in Reserve? HOT 1
- Havent check if callback is avilable
- Delayed job executes now
- Possible to support multiple beanstalkd servers? HOT 3
- Reserve doesn't respond after use tube HOT 3
- Multiple worker HOT 3
- Not an issue don't flag it! Missed something in the great doc HOT 2
- Handlers issues HOT 2
- runner, why class?
- is connected method?
- eslint should only be in devDependencies HOT 2
- SyntaxError: Unexpected token HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fivebeans.