Shutdown hook for Rails

后端 未结 3 1309
时光说笑
时光说笑 2021-01-08 00:35

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 ca

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-08 01:06

    Probably should just use the Ruby exit handler, which is a Kernel method:

    $ irb
    >> at_exit do
    ?>   puts 'bye...'
    >> end
    => #
    >> exit
    bye...
    $ 
    

提交回复
热议问题