Commit 7787878b authored by an.nguyen's avatar an.nguyen
Browse files

Merge branch '244-delayedjob-config-error' into 'development'

Resolve "delayedjob config error"

Closes #244

See merge request !441
parents bf640def ee3e5b5f
datamailcollector_config = Rails.application.config_for :datamailcollector
if File.exist? Rails.root.join('config', 'datamailcollector.yml')
datamailcollector_config = Rails.application.config_for :datamailcollector
Rails.application.configure do
config.datamailcollector = ActiveSupport::OrderedOptions.new
config.datamailcollector.server = datamailcollector_config[:server]
config.datamailcollector.port = datamailcollector_config[:port]
config.datamailcollector.ssl = datamailcollector_config[:ssl]
config.datamailcollector.mail_address = datamailcollector_config[:mail_address]
config.datamailcollector.password = datamailcollector_config[:password]
Rails.application.configure do
config.datamailcollector = ActiveSupport::OrderedOptions.new
config.datamailcollector.server = datamailcollector_config[:server]
config.datamailcollector.port = datamailcollector_config[:port]
config.datamailcollector.ssl = datamailcollector_config[:ssl]
config.datamailcollector.mail_address = datamailcollector_config[:mail_address]
config.datamailcollector.password = datamailcollector_config[:password]
end
end
......@@ -8,6 +8,15 @@
# Delayed::Worker.raise_signal_exceptions = :term
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
if Rails.env.production?
Delayed::Job.enqueue(CollectDataFromMailJob.new, cron: '*/5 * * * *') if Delayed::Job.where("handler like ?", "%CollectDataFromMailJob%").empty?
if Rails.env.production? && Delayed::Job.column_names.include?('cron')
if Rails.configuration.datamailcollector
CollectDataFromMailJob.set(cron: '*/15 * * * *').perform_later if Delayed::Job.where("handler like ?", "%CollectDataFromMailJob%").empty?
else
Delayed::Job.where("handler like ?", "%CollectDataFromMailJob%").destroy_all
end
if Rails.configuration.datacollector
CollectDataFromDevicesJob.set(cron: '*/5 * * * *').perform_later if Delayed::Job.where("handler like ?", "%CollectDataFromDevicesJob%").empty?
else
Delayed::Job.where("handler like ?", "%CollectDataFromDevicesJob%").destroy_all
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment