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 "rake"
|
||||
gem "osmlib-base"
|
||||
gem "sys-proctable"
|
||||
@ -14,6 +14,7 @@ GEM
|
||||
json (1.6.5)
|
||||
osmlib-base (0.1.4)
|
||||
rake (0.9.2.2)
|
||||
sys-proctable (0.9.1)
|
||||
term-ansicolor (1.0.7)
|
||||
|
||||
PLATFORMS
|
||||
@ -23,3 +24,4 @@ DEPENDENCIES
|
||||
cucumber
|
||||
osmlib-base
|
||||
rake
|
||||
sys-proctable
|
||||
|
||||
8
Rakefile
8
Rakefile
@ -2,6 +2,7 @@ require 'OSM/StreamParser'
|
||||
require 'socket'
|
||||
require 'digest/sha1'
|
||||
require 'cucumber/rake/task'
|
||||
require 'sys/proctable'
|
||||
|
||||
SANDBOX = 'sandbox'
|
||||
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
|
||||
process_list = `ps -o pid -o state -o ucomm`
|
||||
process_list.scan /(\d+)\s+([^\s]*)\s+(#{name})/ do |pid,state|
|
||||
yield pid.to_i, state.strip if ['I','R','S','T'].include? state[0]
|
||||
Sys::ProcTable.ps do |process|
|
||||
if process.comm.strip == name.strip
|
||||
yield process.pid.to_i, process.state.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
require 'socket'
|
||||
require 'sys/proctable'
|
||||
|
||||
class OSRMLauncher
|
||||
def initialize &block
|
||||
@ -11,9 +12,10 @@ class OSRMLauncher
|
||||
end
|
||||
|
||||
def each_process name, &block
|
||||
process_list = `ps -o pid -o state -o ucomm`
|
||||
process_list.scan /(\d+)\s+([^\s]*)\s+(#{name})/ do |pid,state|
|
||||
yield pid.to_i, state.strip if ['I','R','S','T'].include? state[0]
|
||||
Sys::ProcTable.ps do |process|
|
||||
if process.comm.strip == name.strip
|
||||
yield process.pid.to_i, process.state.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user