Class: ForemanResourceQuota::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- ForemanResourceQuota::Engine
- Defined in:
- lib/foreman_resource_quota/engine.rb
Class Method Summary collapse
-
.register_scheduled_task(task_class, cronline) ⇒ Object
Helper to register ForemanTasks.
Class Method Details
.register_scheduled_task(task_class, cronline) ⇒ Object
Helper to register ForemanTasks
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/foreman_resource_quota/engine.rb', line 75 def self.register_scheduled_task(task_class, cronline) return if ::ForemanTasks::RecurringLogic.joins(:tasks) .merge(::ForemanTasks::Task.where(label: task_class.name)) .exists? ::ForemanTasks::RecurringLogic.transaction(isolation: :serializable) do User.as_anonymous_admin do recurring_logic = ::ForemanTasks::RecurringLogic.new_from_cronline(cronline) recurring_logic.save! recurring_logic.start(task_class) end end rescue ActiveRecord::TransactionIsolationError => e Rails.logger.warn "ForemanResourceQuota: skipping RecurringLogic registration hook (#{e})" end |