diff --git a/Procfile b/Procfile index 48931e8d..95f93cb5 100644 --- a/Procfile +++ b/Procfile @@ -1 +1,2 @@ cleanup: rake cleanup:everything +stats: bundle exec rake stats:process_all diff --git a/lib/tasks/stats.rake b/lib/tasks/stats.rake new file mode 100644 index 00000000..9461782a --- /dev/null +++ b/lib/tasks/stats.rake @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +namespace :stats do + desc 'Process stats' + task process_all: :environment do + Site.all.pluck(:id).each do |site_id| + UriCollectionJob.perform_now site_id: site_id, once: true + StatCollectionJob.perform_now site_id: site_id, once: true + end + end +end diff --git a/monit.conf b/monit.conf index a524c468..3aa37842 100644 --- a/monit.conf +++ b/monit.conf @@ -8,3 +8,8 @@ check program access_logs with path "/srv/bin/access_logs" as uid "rails" and gid "www-data" every "0 0 * * *" if status != 0 then alert + +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