本文介绍了滑轨的关闭钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Rails关闭时运行一些清理代码-可能吗?我的情况是,我在后台有一些线程(我正在使用jruby并调用java)在整个进程的生命周期中都存在,我需要让他们知道关闭自己的线程
I'd like to have some cleanup code run when Rails is shutting down - is that possible? My situation is that I have a few threads in the background (I'm using jruby and calling into java) that live for the life of the process and I need to let them know to shut themselves down
谢谢!
推荐答案可能应该只使用Ruby退出处理程序,这是一个内核方法:
Probably should just use the Ruby exit handler, which is a Kernel method:
$ irb >> at_exit do ?> puts 'bye...' >> end => #<Proc:0xb79a87e4@(irb):1> >> exit bye... $更多推荐
滑轨的关闭钩
发布评论