Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,19 @@ def process_matcher(pid)
if pid == own_pid
return false
end
File.read("/proc/#{pid}/cmdline").include?("codedeploy-agent: master")
File.read("/proc/#{pid}/cmdline").include?("codedeploy-agent: master") rescue false
end

def handle_pid_file
def handle_pid_file
@file_lock ||= File.open(pid_lock_file, File::RDWR|File::CREAT, 0644)
lock_acquired = @file_lock.flock(File::LOCK_EX | File::LOCK_NB)

if lock_acquired == false
ProcessManager::Log.info("Could not acquire lock on #{pid_lock_file} - aborting start!")
self.class.abort
elsif File.exists?(pid_file)
pid = self.class.find_pid
if ProcessManager.process_running?(pid) and process_matcher(pid)
if pid && ProcessManager.process_running?(pid) && process_matcher(pid)
puts "Pidfile #{pid_file} exists and process #{pid} is running - aborting start!"
ProcessManager::Log.info("Pidfile #{pid_file} exists and process #{pid} is running - aborting start!")
@file_lock.close
Expand Down Expand Up @@ -315,7 +315,7 @@ def self.clean_stale_pid
end

def self.find_pid
File.read(pid_file).chomp.to_i rescue nil
Integer(File.read(pid_file).chomp) rescue nil
end

def description(pid = $$)
Expand Down