Sup*_*ave 6 ruby ruby-on-rails ruby-on-rails-4
在生产模式下部署rails应用程序后,是否需要安排定期清理rails tmp目录?aka:rake tmp:clear(或其子部分tmp:sessions:clear,tmp:cache:clear,tmp:sockets:clear).
我知道rails的几个主要版本,这是需要做的事情.我目前正在使用Rails 4.1.x. 谢谢.
将其中一个或多个添加到您的crontab文件中,这应该为您做...
rake tmp:cache:clear
rake tmp:clear
rake tmp:create
rake tmp:sessions:clear
rake tmp:sockets:clear
Run Code Online (Sandbox Code Playgroud)
请记住,清除会话将杀死所有活动会话。我不建议那样。您可以创建一个名为:
定期包含以下内容:
def self.run
CGI::Session::ActiveRecordStore::Session.
destroy_all( ['updated_at <?', 48.hours.ago] )
end
Run Code Online (Sandbox Code Playgroud)
然后像这样cron你的脚本/运行器
script/runner -e production Periodic.run
Run Code Online (Sandbox Code Playgroud)
以下是Rails 6rails --tasks在清除 tmp 目录方面的内容。
rails tmp:clear # Clear cache, socket and screenshot files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear, tmp:screenshots:clear)
rails tmp:create # Creates tmp directories for cache, sockets, and pids
Run Code Online (Sandbox Code Playgroud)
注意:它在评论中确实提到了tmp:cache:clear, tmp:sockets:clear, 。tmp:screenshots:cleartmp:clear
对我来说,我的缓存填满了 Docker 容器并耗尽了 inode,因此看起来磁盘空间已耗尽。我将尝试配置生产的缓存设置来帮助解决这个问题。
听起来如果您想让文件缓存自动过期,您可以执行以下操作:Rails:控制文件存储缓存大小。他们提到使用:expires_in文件缓存,否则您可以使用类似的内容设置内存大小限制config.cache_store = :memory_store, { size: 64.megabytes }
另外,这里还有关于缓存的当前文档,其中也提到了:expires_in
| 归档时间: |
|
| 查看次数: |
4245 次 |
| 最近记录: |