diff --git a/lib/puma_auto_tune/defaults/ram/wrappers.rb b/lib/puma_auto_tune/defaults/ram/wrappers.rb index 9159391..0a2eee1 100644 --- a/lib/puma_auto_tune/defaults/ram/wrappers.rb +++ b/lib/puma_auto_tune/defaults/ram/wrappers.rb @@ -1,19 +1,20 @@ PumaAutoTune.hooks(:ram) do |auto| - auto.wrap(:reap_cycle) do |block| + auto.wrap(:reap_cycle) do |orig| Proc.new do |resource, master, workers| ends_at = Time.now + PumaAutoTune.reap_duration while Time.now < ends_at sleep 1 - block.call(*auto.args) + orig.call(*auto.args) end end end - auto.wrap(:remove_worker) do |block| + auto.wrap(:cycle) do |orig| Proc.new do |resource, master, workers| - resource.reset - PumaAutoTune.max_worker_limit = workers.size - 1 - block.call(*auto.args) + loop do + sleep PumaAutoTune.frequency + orig.call(*auto.args) if master.running? + end end end end diff --git a/lib/puma_auto_tune/hook.rb b/lib/puma_auto_tune/hook.rb index bfcb10f..b94306a 100644 --- a/lib/puma_auto_tune/hook.rb +++ b/lib/puma_auto_tune/hook.rb @@ -32,10 +32,7 @@ def wrap_hook(name, &block) def auto_cycle Thread.new do - loop do - sleep PumaAutoTune.frequency - call(:cycle) if @resource.master.running? - end + self.call(:cycle) end end