Skip to content

Commit

Permalink
adding ability to pause the nsqd process to make timeouts testable
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrumm authored and chen-anders committed Nov 30, 2023
1 parent 75dbae2 commit 652dfff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/nsq-cluster/process_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ProcessWrapper

def initialize(opts = {}, verbose = false)
@verbose = verbose
@process_paused = false
end


Expand All @@ -17,12 +18,25 @@ def start(opts = {})

def stop(opts = {})
raise "#{command} is not running" unless running?
Process.kill('CONT', @pid) if @process_paused
Process.kill('TERM', @pid)
Process.waitpid(@pid)
@pid = nil
block_until_stopped unless opts[:async]
end

def pause_process(opts = {})
raise "#{command} is not running" unless running?
@process_paused = true
Process.kill('TSTP', @pid)
end

def resume_process(opts = {})
raise "#{command} is not running" unless running?
@process_paused = false
Process.kill('CONT', @pid)
end


def destroy
stop(async: true) if running?
Expand Down

0 comments on commit 652dfff

Please sign in to comment.