4

当 Rails 应用程序关闭时,遵循的程序是什么?我如何才能使用它来清理在 Rails 应用程序运行期间创建的文件?

4

1 回答 1

6

您可以添加以下块以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...
于 2012-02-19T18:28:00.223 回答