don't fail restarting delayed jobs if the pid file is orphaned

previously, delayed_job restart/stop would fail if the pid file was
there, but the process didn't exist

test plan: start delayed jobs, then kill -9 the pool. then try
restarting delayed jobs, it'll still be successful.

Change-Id: Iaedbdc6c0381a6f79ab488eefd19344645e3e2df
Reviewed-on: https://gerrit.instructure.com/8266
Reviewed-by: Brian Palmer <brianp@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Brian Palmer 2012-01-24 15:32:37 -07:00
parent 51f1d9273b
commit 6dd5a15064
1 changed files with 8 additions and 3 deletions

View File

@ -219,7 +219,11 @@ class Pool
pid = File.read(pid_file) if File.file?(pid_file)
if pid.to_i > 0
puts "Stopping pool #{pid}..."
Process.kill('INT', pid.to_i)
begin
Process.kill('INT', pid.to_i)
rescue Errno::ESRCH
# ignore if the pid no longer exists
end
else
status
end
@ -227,12 +231,13 @@ class Pool
def status(print = true)
pid = File.read(pid_file) if File.file?(pid_file)
if pid
alive = pid && pid.to_i > 0 && Process.kill(0, pid.to_i) rescue false
if alive
puts "Delayed jobs running, pool PID: #{pid}" if print
else
puts "No delayed jobs pool running" if print
end
pid.to_i > 0 ? pid.to_i : nil
alive
end
def read_config(config_filename)