Technical recipes for frequently and infrequently recurring problems
Various processes that Hyrax runs (e.g., ffmpeg, imagemagick, browse_everything) leave temporary files in the /tmp directory. Over time, these build up and fill up the disk, causing errors. To prevent this, put a cron job in place to remove them on a regular basis.
Also, Blacklight saves user searches, and over time these will fill up the database. They also need to be deleted regularly.
gem 'whenever', require: false
wheneverize .
config/schedule.rb
and add: # Delete blacklight saved searches
every :day, at: '11:55pm' do
rake "blacklight:delete_old_searches[1]"
end
# Remove files in /tmp owned by the deploy user that are older than 7 days
every :day, at: '1:00am' do
command "/usr/bin/find /tmp -type f -mtime +7 -user deploy -execdir /bin/rm -- {} \\;"
end
Capfile
file: # use whenever to manage cron jobs
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
Now, when you deploy the code, it will create the relevant cron jobs for the deploy user.