Skip to content

Instantly share code, notes, and snippets.

@informz
Last active August 29, 2015 14:23
Show Gist options
  • Save informz/5c728bfdb515b6e3cbad to your computer and use it in GitHub Desktop.
Save informz/5c728bfdb515b6e3cbad to your computer and use it in GitHub Desktop.
potential resource cleanup code
hook = java.lang.Thread.new do
# puts '[DEBUG] shutdown hook'
# java.lang.Thread.get_all_stack_traces.key_set.each do | thread |
# puts '[DEBUG] stopping'
# begin
# thread.stop
# rescue java.lang.Throwable => t
# puts t
# end
#
# puts '[DEBUG] stopped'
# end
# puts '[DEBUG] shutdown complete'
end
java.lang.Runtime.get_runtime().add_shutdown_hook(hook)
at_exit do
#puts '[DEBUG] shutting down ruby'
# java.lang.Thread.get_all_stack_traces.key_set.each do | thread |
# # puts '[DEBUG] stopping'
# begin
# thread.stop
# rescue java.lang.Throwable => t
# puts t
# end
#
# # puts '[DEBUG] stopped'
# end
#java.lang.System.exit(0)
# scheduler = StdSchedulerFactory.new.get_scheduler()
#
# scheduler.standby # don't trigger new jobs
# scheduler.getCurrentlyExecutingJobs.each do |job_context|
# puts "killing job #{job_context.job_detail.key}"
# scheduler.interrupt(job_context.job_detail.key) # interrupt job
# end
#
# scheduler.shutdown(true)
# puts '[DEBUG] ruby is shut down'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment