Comments (8)
Well, I see that I am not calling .join()
on the worker thread, ala
try { workerThread.join(); } catch (Exception e){ e.printStackTrace(); }
in the example. Calling that after I call worker.end(true)
does seem to remove the Worker from Resque, throwing a
WARN net.greghaines.jesque.worker.WorkerImpl - Terminating in response to exception
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at net.greghaines.jesque.worker.WorkerImpl.poll(WorkerImpl.java:459)
at net.greghaines.jesque.worker.WorkerImpl.run(WorkerImpl.java:206)
at java.lang.Thread.run(Thread.java:680)
in the process though
from jesque.
Does the worker thread stop? Use jstack to see if the worker threads are still running.
Worker.end(true) can't stop the thread while the thread is busy processing a job. How long running are your jobs?
On Oct 29, 2011, at 7:52 PM, Cody [email protected] wrote:
I am spinning up Workers and they're processing jobs just fine. I use the existence of a control file to request workers to shut down.
Even though I am calling
worker.end(true);
The worker is still in Resque, waiting for a job. I am monitoring the redis stream using
redis-cli monitor
and dont see any commands to remove this worker.for(Worker w : avatarWorkers) { if(w != null) { log.info("Stopping avatar worker: " + w.toString()); w.end(true); } }Results log messages like:
2011-10-29 16:42:58,436 [main] INFO com.batch.App - Stopping avatar worker: dev:worker:Codys-MacBook-Pro.local:10065-6:JAVA_DYNAMIC_QUEUES,avatars
But they're stil in Resque / Redis.
Am I doing something wrong?
Reply to this email directly or view it on GitHub:
#11
from jesque.
Calling join()
simply tells the current thread to wait until the worker thread stops. The true
in end(true)
is teling the worker to attempt to interrupt a job in-progress and it does this by calling Thread.interrupt()
on the worker thread. Now, a job will only stop if it is in a method checks for interrupts (e.g.: Thread.sleep()
, any I/O task, Object.wait()
, etc.)
The warning in your last post is from the worker being interrupted while waiting on a job to arrive and this is the desired behavior.
If you're still having problems with the workers not shutting down, use the JDK's jstack
command-line tool to get a stack trace of all currently running threads in your process and I'll help you interpret the output.
from jesque.
Let me know if you need any help with this; threads are a sticky subject and I always ask for a second pair of eyeballs when I'm writing a multi-threaded app.
from jesque.
Thank you for being on top of this.
I've made some changes to the code but it won't get deployed today. Namely, I was not waiting for the thread to finish after calling worker.end(true) - that is, I wasn't calling Thread.join on the worker thread. I don't know how important that is.
Anyways, I will try and dig into this more and keep you posted.
Thanks.
On Oct 31, 2011, at 8:07 AM, Greg Haines wrote:
Let me know if you need any help with this; threads are a sticky subject and I always ask for a second pair of eyeballs when I'm writing a multi-threaded app.
Reply to this email directly or view it on GitHub:
#11 (comment)
from jesque.
It appears this problem was on my end the whole time.
I am using a Sun JVM and was capturing the signal via:
Signal.handle(new Signal("TERM"), new SignalHandler() {
public void handle(final Signal sig) {
log.info("Caught TERM signal");
shutdown();
System.exit(0);
}
});
And I was running my code via a terminal session, and using ctrl+c
to kill the process. My error was that I assumed ctrl+c
sends a TERM
signal, but in fact it sends a INT
signal, which I wasnt registered to receive.
Thus I was never giving Jesque a chance to clean up after itself.
Sorry to waste your time.
from jesque.
No problem. Glad you figured it out.
from jesque.
@ruckus I found this tip to avoid Sun-specific code: http://stackoverflow.com/a/2541950/418602
I got to the bottom of my similar problem by reading through this issue, so thanks for raising it 👍 even if it wasn't technically a 🐛 😉
from jesque.
Related Issues (20)
- java.net.UnknownHostException thrown when `ip-#-#-#-#` pattern has no reverse lookup HOT 2
- No worker running when facing `Terminating in response to exception`
- jackson 2.9 incompatibility
- jackson databind 2.9 includes a breaking change HOT 5
- successful job is re-enqueued during shutdown HOT 1
- Worker queue in redis not reset when restarting?
- client.enqueue() error `java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.DeserializationConfig.with` HOT 1
- Throw JedisDataException when enqueue a job HOT 1
- Requesting new public release. HOT 1
- Version 2.1.3 breaks API compatibility from 2.1.2 HOT 1
- why does jesque not use namespace as prefix for recurring jobs? HOT 2
- RESET_TO_HIGHEST_PRIORITY Strategy not work for recurring job
- Implement a way to set FailQueueStrategy on WorkerImplFactory
- Jedis 3.X compatibility HOT 9
- NoSuchConstructorException HOT 1
- 通过jesque的延时任务实现支持cron表达式的调度任务 HOT 1
- Redis Cluster Issue
- ETA on current master release HOT 1
- Job moved from inflight queue to comma-joined queue on worker shutdown in RESET_TO_HIGHEST_PRIORITY strategy.
- Worker existing on uncaught exception after 10 minutes of no connection
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 jesque.