Class: WebSocket::ShutdownHook
Overview
The ShutdownHook class specifies a routine to be invoked when the java runtime is shutdown.
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server) ⇒ ShutdownHook
constructor
A new instance of ShutdownHook.
- #run ⇒ Object
Constructor Details
#initialize(server) ⇒ ShutdownHook
Returns a new instance of ShutdownHook.
22 23 24 25 26 |
# File 'lib/websocket/shutdown_hook.rb', line 22 def initialize(server) super() @server = server java.lang.Runtime.runtime.add_shutdown_hook(self) end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
20 21 22 |
# File 'lib/websocket/shutdown_hook.rb', line 20 def server @server end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 |
# File 'lib/websocket/shutdown_hook.rb', line 28 def run $stdout.write "\r\e[0K" $stdout.flush ::WebSocket::Server.log.info 'Shutting down' server.shutdown if server.respond_to?(:shutdown) end |