After I deploy a rails application in production mode, do I need to schedule a periodic cleanup of the rails tmp directory? aka: rake tmp:clear (or its sub-parts tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear).
I know a few major revisions of rails back this was something that was needed to be done. I'm currently using Rails 4.1.x. Thanks.
Add one or more of those to your crontab file and that should do it for you...
rake tmp:cache:clear
rake tmp:clear
rake tmp:create
rake tmp:sessions:clear
rake tmp:sockets:clear
Keep in mind, clearing sessions will kill all active sessions to. I don't recommend that. You could create a model called:
Periodic with something like this in it:
def self.run
CGI::Session::ActiveRecordStore::Session.
destroy_all( ['updated_at <?', 48.hours.ago] )
end
then cron your script/runner like this
script/runner -e production Periodic.run
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With