在Rails应用程序上执行操作关闭
答
您可以在以下块添加到config/boot.rb
运行命令,当应用程序被关闭:
at_exit do
puts "Shutting the app down..."
end
这是你在你的服务器过程中看到输出:
[Swanny ~/Sites/test_app]$ bundle exec thin start
>> Using rack adapter
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
^C>> Stopping ...
Shutting the app down...