Module: Aeternitas::Maintenance
- Defined in:
- lib/aeternitas/maintenance.rb
Overview
Provides methods for cleaning up Aeternitas data.
Class Method Summary collapse
- .cleanup_all ⇒ Object
-
.cleanup_old_metrics ⇒ Object
Clean up old metric records to prevent the table from growing too large.
-
.cleanup_stale_locks ⇒ Object
Clean up stale job and guard locks that have passed their expiration.
Class Method Details
.cleanup_all ⇒ Object
4 5 6 7 |
# File 'lib/aeternitas/maintenance.rb', line 4 def self.cleanup_all cleanup_stale_locks cleanup_old_metrics end |
.cleanup_old_metrics ⇒ Object
Clean up old metric records to prevent the table from growing too large.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aeternitas/maintenance.rb', line 23 def self.cleanup_old_metrics logger = ActiveJob::Base.logger cutoff_date = Aeternitas.config.metric_retention_period.ago logger.info "Cleaning up Aeternitas metrics older than #{cutoff_date}..." metrics_deleted = Aeternitas::Metric.where("created_at < ?", cutoff_date).delete_all logger.info " - Deleted #{metrics_deleted} old metric records." logger.info "Old metrics cleanup complete." end |
.cleanup_stale_locks ⇒ Object
Clean up stale job and guard locks that have passed their expiration.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/aeternitas/maintenance.rb', line 10 def self.cleanup_stale_locks logger = ActiveJob::Base.logger logger.info "Cleaning up stale Aeternitas locks..." unique_job_locks_deleted = Aeternitas::UniqueJobLock.where("expires_at < ?", Time.current).delete_all guard_locks_deleted = Aeternitas::GuardLock.where("locked_until < ?", Time.current).delete_all logger.info " - Deleted #{unique_job_locks_deleted} stale unique job locks." logger.info " - Deleted #{guard_locks_deleted} stale guard locks." logger.info "Stale lock cleanup complete." end |