lib/silver_spurs/asyncifier.rb in silver_spurs-1.0.1 vs lib/silver_spurs/asyncifier.rb in silver_spurs-1.0.2
- old
+ new
@@ -26,21 +26,21 @@
end
def spawn_process(process_name, command)
create_directory_tree
logged_command = "#{command} 1> #{log_file_path process_name} 2>&1 && touch #{success_file_path process_name}"
- logger.debug "Executing: #{logger_command}"
+ logger.debug "Executing: #{logged_command}"
pid = Process.spawn logged_command
File.open(pid_file_path(process_name), 'wb') { |f| f.write pid }
Process.detach pid
end
def has_lock?(process_name)
return false unless File.exists? pid_file_path(process_name)
pid = File.read(pid_file_path(process_name)).to_i
- `ps -o command -p #{pid}`.split("\n").count == 2
+ IO.popen("ps -o command -p #{pid}").read.split("\n").count == 2
end
def success?(process_name)
return false unless File.exists? success_file_path(process_name)
return true unless File.exists? pid_file_path(process_name)
@@ -61,10 +61,10 @@
pid = File.read(pid_file_path(process_name)).to_i
Process.kill 'KILL', pid
sleep 1
Process.kill('TERM', pid) if has_lock? process_name
end
- reap_lock_if_done process_name
+ reap_orphaned_lock process_name
end
def reap_old_process(process_name)
if has_lock? process_name
launch_time = File.mtime pid_file_path(process_name)