在Rails应用程序上执行操作关闭

在Rails应用程序上执行操作关闭

问题描述:

当Rails应用程序进入关闭状态时,遵循的过程是什么?我怎样才能在这里清理运行Rails应用程序期间创建的文件?在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...