Shutdown hook for Rails

2019-02-16 22:16发布

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

Thanks!

1条回答
贪生不怕死
2楼-- · 2019-02-16 23:00

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...
$ 
查看更多
登录 后发表回答