Migrated AppVersionRestartJob to Active Job.

This commit is contained in:
Jens Pfeifer 2018-12-13 15:40:22 +01:00
parent 6e3f32825f
commit a92f7b2153
4 changed files with 19 additions and 12 deletions

View 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

View file

@ -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

View file

@ -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

View 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