Closed michal-kazmierczak closed 2 years ago
Hi @michal-kazmierczak ,
That's a really good question and a very fair point. I think I can suggest a workaround, though I might need to consider something more integrated for the version 0.8 line.
The workaround I'm thinking of will leverage the Iodine.on_state
method along with the Iodine.run_every
method to create a custom timeout. Something like this:
Iodine.on_state(:start_shutdown) do
Iodine.run_every(milliseconds: 20000) do
Process.kill("INT", Process.pid)
end
end
This should end the graceful shutdown (the second SIGINT
forces iodine to immediately shutdown)... if this isn't strong enough use a more terminal signal such as SIGKILL
.
Since only the worker processes are being shutdown they will be the only ones subject to the timer during a hot restart (the main process will be subject to the timeout during shutdown, but you can add a simple if
statement to negate that, if you want).
Good Luck!
Thank you @boazsegev for your prompt reply. I'll try the suggested solution. I'm closing the issue. In case of problems, I'll come back and reopen.
Hello @boazsegev
let me start by saying thank you for bringing Iodine to the Ruby world.
I wanted to ask if there is any way to force hot restarts (
SIGUSR1
) after a certain timeout passes.I run an Iodine websocket server with multiple workers. I observe that sometimes hot restarts take a lot of time (even ~10mins). I suspect that Iodine tries to perform a graceful shutdown attempting to flush the sockets before terminating the connection (are there other conditions stopping a worker from being restarted?). Unfortunately, a slow client may prevent that causing the whole instance to be unavailable until the restart finishes.