Migrated AppVersionRestartJob to Active Job.
This commit is contained in:
parent
6e3f32825f
commit
a92f7b2153
4 changed files with 19 additions and 12 deletions
7
app/jobs/app_version_restart_job.rb
Normal file
7
app/jobs/app_version_restart_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class AppVersionRestartJob < ApplicationJob
|
||||
def perform(cmd)
|
||||
Rails.logger.info "executing CMD: #{cmd}"
|
||||
::Kernel.system(cmd)
|
||||
Rails.logger.info "executed CMD: #{cmd}"
|
||||
end
|
||||
end
|
|
@ -768,7 +768,7 @@ to send no browser reload event, pass false
|
|||
if ENV['APP_RESTART_CMD']
|
||||
AppVersion.set(true, 'restart_auto')
|
||||
sleep 4
|
||||
Delayed::Job.enqueue(Observer::AppVersionRestartJob.new(ENV['APP_RESTART_CMD']))
|
||||
AppVersionRestartJob.perform_later(ENV['APP_RESTART_CMD'])
|
||||
else
|
||||
AppVersion.set(true, 'restart_manual')
|
||||
end
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
class Observer::AppVersionRestartJob
|
||||
def initialize(cmd)
|
||||
@cmd = cmd
|
||||
end
|
||||
|
||||
def perform
|
||||
Rails.logger.info "executing CMD: #{@cmd}"
|
||||
system(@cmd)
|
||||
Rails.logger.info "executed CMD: #{@cmd}"
|
||||
end
|
||||
end
|
11
spec/jobs/app_version_restart_job_spec.rb
Normal file
11
spec/jobs/app_version_restart_job_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AppVersionRestartJob, type: :job do
|
||||
|
||||
let(:cmd) { '/path/to/restart_script.sh' }
|
||||
|
||||
it 'executes app version restart job' do
|
||||
expect(::Kernel).to receive(:system).with(cmd)
|
||||
described_class.perform_now(cmd)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue