Skip to content

Commit

Permalink
Merge pull request #81 from DmitryBochkarev/SERVICES-1092
Browse files Browse the repository at this point in the history
fix: запуск GC при завершении работы воркеров
  • Loading branch information
bibendi committed May 17, 2016
2 parents 0a3bd6a + d262d6e commit 35cb66c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/resque/integration/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ def failure_notifier
@notifier ||= Notifier.new(self['failure.notifier'])
end

# Returns flag for cleaning on shutdown see https://github.com/resque/resque/issues/1167
def run_at_exit_hooks?
value = self['resque.run_at_exit_hooks']

if value.is_a?(String) && %w(n no false off disabled).include?(value)
value = false
end

value.nil? ? true : value
end

# Returns Resque polling interval
def interval
(self['resque.interval'] || 5).to_i
Expand Down
4 changes: 4 additions & 0 deletions lib/resque/integration/tasks/hooks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ namespace :resque do
if Resque.config.resque_scheduler? && Resque.config.schedule_exists?
Resque.schedule = YAML.load_file(Resque.config.schedule_file)
end

if Resque.config.run_at_exit_hooks? && ENV['RUN_AT_EXIT_HOOKS'].nil?
ENV['RUN_AT_EXIT_HOOKS'] = '1'
end
end
end
12 changes: 12 additions & 0 deletions spec/resque/integration/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
it { expect(config.resque_scheduler?).to be_false }
end
end

describe '#run_at_exit_hooks?' do
context 'when default' do
it { expect(config.resque_scheduler?).to be_true }
end

context 'when defined' do
let(:config_yaml) { {'resque' => {'run_at_exit_hooks' => 'no'}} }

it { expect(config.run_at_exit_hooks?).to be_false }
end
end
end

describe Resque::Integration::Configuration::Notifier do
Expand Down

0 comments on commit 35cb66c

Please sign in to comment.