From ae7481550a3c6d92c0cbe34df6c2c72cbdcc94fd Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:12:10 -0300 Subject: [PATCH] feat: hacer limpieza de emergencia #12854 --- Procfile | 2 +- lib/tasks/cleanup.rake | 3 ++- monit.conf | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Procfile b/Procfile index 4cc6e5b3..14bdb0c5 100644 --- a/Procfile +++ b/Procfile @@ -8,4 +8,4 @@ prometheus: bundle exec prometheus_exporter -b 0.0.0.0 --prefix "sutty_" distributed_press_tokens_renew: bundle exec rake distributed_press:tokens:renew cleanup: bundle exec rake cleanup:everything stats: bundle exec rake stats:process_all -distributed_press_renew_tokens: bundle exec rake distributed_press:tokens:renew +emergency_cleanup: bundle exec rake cleanup:everything BEFORE=7 diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index 1c52abaf..20044871 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -2,8 +2,9 @@ namespace :cleanup do desc 'Cleanup sites' - task everything: :environment do + task everything: :environment do |_, args| before = ENV.fetch('BEFORE', '30').to_i.days.ago + CleanupJob.perform_later(before) end end diff --git a/monit.conf b/monit.conf index 0bd18907..b0aa9884 100644 --- a/monit.conf +++ b/monit.conf @@ -19,7 +19,6 @@ check program stats every "0 1 * * *" if status != 0 then alert -check program distributed_press_tokens_renew - with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data" - every "0 3 * * *" - 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"