Skip to content

Commit

Permalink
Extra logging + Process.wait.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 29, 2025
1 parent df145c4 commit 2685eaf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions spec/daemonizing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,27 @@ def name
end

it 'should kill process in pid file' do
$stderr.puts "Pid file should not exist: #{subject.pid_file}"
expect(File.exist?(subject.pid_file)).to be_falsey

fork do
$stderr.puts "Forking..."
pid = fork do
subject.daemonize
sleep
end

wait_for_server_to_start

$stderr.puts "Pid file should exist: #{subject.pid_file} pid=#{pid}"
expect(File.exist?(subject.pid_file)).to be_truthy

$stderr.puts "Killing..."
silence_stream STDOUT do
subject.kill(1)
end

sleep(1)
$stderr.puts "Waiting for process to die..."
Process.wait(pid)
expect(File.exist?(subject.pid_file)).to be_falsey
end

Expand Down Expand Up @@ -184,7 +189,9 @@ def name
private

def wait_for_server_to_start
$stderr.puts "Waiting for server to start... pid_file=#{subject.pid_file}"
until File.exist?(subject.pid_file)
$stderr.puts "Sleeping..."
sleep(0.1)
end
end
Expand Down

0 comments on commit 2685eaf

Please sign in to comment.