use ruby to fetch process list
This commit is contained in:
parent
e2a3fb5c61
commit
a8e9b148eb
1
Gemfile
1
Gemfile
@ -3,3 +3,4 @@ source "http://rubygems.org"
|
|||||||
gem "cucumber"
|
gem "cucumber"
|
||||||
gem "rake"
|
gem "rake"
|
||||||
gem "osmlib-base"
|
gem "osmlib-base"
|
||||||
|
gem "sys-proctable"
|
||||||
@ -14,6 +14,7 @@ GEM
|
|||||||
json (1.6.5)
|
json (1.6.5)
|
||||||
osmlib-base (0.1.4)
|
osmlib-base (0.1.4)
|
||||||
rake (0.9.2.2)
|
rake (0.9.2.2)
|
||||||
|
sys-proctable (0.9.1)
|
||||||
term-ansicolor (1.0.7)
|
term-ansicolor (1.0.7)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
@ -23,3 +24,4 @@ DEPENDENCIES
|
|||||||
cucumber
|
cucumber
|
||||||
osmlib-base
|
osmlib-base
|
||||||
rake
|
rake
|
||||||
|
sys-proctable
|
||||||
|
|||||||
8
Rakefile
8
Rakefile
@ -2,6 +2,7 @@ require 'OSM/StreamParser'
|
|||||||
require 'socket'
|
require 'socket'
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
require 'cucumber/rake/task'
|
require 'cucumber/rake/task'
|
||||||
|
require 'sys/proctable'
|
||||||
|
|
||||||
SANDBOX = 'sandbox'
|
SANDBOX = 'sandbox'
|
||||||
DATA_FOLDER = 'osm_data'
|
DATA_FOLDER = 'osm_data'
|
||||||
@ -30,9 +31,10 @@ task osm_data_area_name.to_sym {} #define empty task to prevent rake from whin
|
|||||||
|
|
||||||
|
|
||||||
def each_process name, &block
|
def each_process name, &block
|
||||||
process_list = `ps -o pid -o state -o ucomm`
|
Sys::ProcTable.ps do |process|
|
||||||
process_list.scan /(\d+)\s+([^\s]*)\s+(#{name})/ do |pid,state|
|
if process.comm.strip == name.strip
|
||||||
yield pid.to_i, state.strip if ['I','R','S','T'].include? state[0]
|
yield process.pid.to_i, process.state.strip
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
require 'socket'
|
require 'socket'
|
||||||
|
require 'sys/proctable'
|
||||||
|
|
||||||
class OSRMLauncher
|
class OSRMLauncher
|
||||||
def initialize &block
|
def initialize &block
|
||||||
@ -11,9 +12,10 @@ class OSRMLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def each_process name, &block
|
def each_process name, &block
|
||||||
process_list = `ps -o pid -o state -o ucomm`
|
Sys::ProcTable.ps do |process|
|
||||||
process_list.scan /(\d+)\s+([^\s]*)\s+(#{name})/ do |pid,state|
|
if process.comm.strip == name.strip
|
||||||
yield pid.to_i, state.strip if ['I','R','S','T'].include? state[0]
|
yield process.pid.to_i, process.state.strip
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user