-
Notifications
You must be signed in to change notification settings - Fork 136
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
Graceful Termination #100
Comments
Ah, I have not encountered this. I will look into how best to trap signals and trigger a clean disconnection.
Out of interest, what is the problem you are trying to work round?
- Failing to get to more shutdown code?
- Not causing the broker to deliver the Will message?
- Error messages in log files?
- Just trying to be clean and hygienic?
|
A) Sigint will currently terminate the app in the middle of anything it is doing. This could lead to half-handled messages or similar issues. So, basically the last two, but it's entirely possible that the first one will become an issue. This may also be partially a workflow confusion. How do you normally terminate listening? With the MQTT code being blocking, it's kind of difficult for other code to run. |
It doesn't solve some of the underlying issues, but I actually realized I have a 'better' solution now:
Of course, from here I'm going to spend a lot of time cleaning up -- adding reconnect logic to automatically attempt a reconnect and so on. |
Hi, /var/lib/gems/2.1.0/gems/mqtt-0.5.0/lib/mqtt/client.rb:581: warning: instance variable @last_packet_id not initialized Any ideas? |
Could you post more about your code, @teaching-innovation ? Just the one line isn't helpful to me, though someone who maintains the gem may be able to get more out of it. How are you running it, how are you terminating it, how are you using it, etc etc. |
Hi @rlugge thanks for the follow up: It works ok if I use nohup to run the script. But if I fun it without I continually get 581: warning seen bellow? Any ideas?
|
Could you please format that a little cleaner? It's hard to read all jammed together on one line like that. Use triple backticks offset by line returns to make a code block. |
Hi @rlugge, I thought i did put it in a code block, but now that is has triple backticks it looks better. |
@teaching-innovation not really germane to this forum, but typically single backticks are used for small, inline code snippets, while the triple are used for larger code blocks, that's why you had formatting issues the first time -- it was the code format intended for inline use. As for your issues... are you redefining methods? No clue what could be causing it, to be honest. |
I've managed to work around most of the issues involved in using blocking code, but I've got a small annoyance left.
Because I need this as a long-running process running alongside a rails process, I need to be able to let it run in the background indefinitely, until a termination command is recieved.
So far, my best effort is to trap the Sigint signall and call client.disconnect(), but that simply throws a new error, since synchronize can't be called from trap context.
How am I supposed to trigger a graceful shutdown?
The text was updated successfully, but these errors were encountered: