diff --git a/Procfile b/Procfile index 45fe1df7..e7f4ebb6 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,3 @@ cleanup: bundle exec rake cleanup:everything stats: bundle exec rake stats:process_all +emergency_cleanup: bundle exec rake cleanup:everything[7] diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index 1c52abaf..6ea48c0d 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -2,8 +2,7 @@ namespace :cleanup do desc 'Cleanup sites' - task everything: :environment do - before = ENV.fetch('BEFORE', '30').to_i.days.ago - CleanupJob.perform_later(before) + task everything: :environment do |_, args| + CleanupJob.perform_later((args.extras.first || 30).to_i.days.ago) end end diff --git a/monit.conf b/monit.conf index 39f45d6d..139a401d 100644 --- a/monit.conf +++ b/monit.conf @@ -13,3 +13,7 @@ check program stats with path "/usr/bin/foreman run -f /srv/Procfile -d /srv stats" as uid "rails" gid "www-data" every "0 1 * * *" if status != 0 then alert + +check filesystem root with path / + if space usage > 80% for 5 times within 15 cycles then alert + if space usage > 90% for 5 cycles then exec "/usr/bin/foreman run -f /srv/Procfile -d /srv emergency_cleanup" as uid "rails" gid "www-data"