get process handling up to date
This commit is contained in:
parent
14eac50261
commit
76fb0cb965
@ -45,23 +45,28 @@ class OSRMLoader
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.osrm_up?
|
def self.osrm_up?
|
||||||
if @@pid
|
if @@pid
|
||||||
s = `ps -o state -p #{@@pid}`.split[1].to_s.strip
|
begin
|
||||||
up = (s =~ /^[DRST]/) != nil
|
if Process.waitpid(@@pid, Process::WNOHANG) then
|
||||||
up
|
false
|
||||||
else
|
else
|
||||||
false
|
true
|
||||||
|
end
|
||||||
|
rescue Errno::ESRCH, Errno::ECHILD
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.osrm_up
|
def self.osrm_up
|
||||||
return if self.osrm_up?
|
return if self.osrm_up?
|
||||||
@@pid = Process.spawn("#{BIN_PATH}/osrm-routed --sharedmemory=1 --port #{OSRM_PORT}",:out=>OSRM_ROUTED_LOG_FILE, :err=>OSRM_ROUTED_LOG_FILE)
|
@@pid = Process.spawn("#{BIN_PATH}/osrm-routed --sharedmemory=1 --port #{OSRM_PORT}",:out=>OSRM_ROUTED_LOG_FILE, :err=>OSRM_ROUTED_LOG_FILE)
|
||||||
|
Process.detach(@@pid) # avoid zombie processes
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.osrm_down
|
def self.osrm_down
|
||||||
if @@pid
|
if @@pid
|
||||||
Process.kill 'TERM', @@pid
|
Process.kill TERMSIGNAL, @@pid
|
||||||
self.wait_for_shutdown
|
self.wait_for_shutdown
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user