I am running a Middleman (which uses Webrick) server on JRuby inside a JVM process using the org.jruby.embed.ScriptingContainer
API.
If I shutdown cleanly and stop the server from inside the JVM, everything works as expected.
But if I send a SIGTERM to the JVM process (for example, by hitting ctrl+C at the command line), the console returns but the JVM process does not terminate - it hangs around indefinitely until I send it a SIGKILL.
I tried registering a JVM shutdown hook to terminate the ScriptingContainer
instance, but the hook never fires. I'm not sure why... perhaps JRuby is swallowing the SIGTERM somehow?
How can I get the JVM to shut all the way down, cleanly, even if it contains a running Webrick server?