Class: Droonga::Serf::SerfProcess
- Inherits:
-
Object
- Object
- Droonga::Serf::SerfProcess
- Includes:
- Loggable
- Defined in:
- lib/droonga/serf.rb
Instance Method Summary collapse
-
#initialize(loop, serf, command, *options) ⇒ SerfProcess
constructor
A new instance of SerfProcess.
- #run_once ⇒ Object
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(loop, serf, command, *options) ⇒ SerfProcess
Returns a new instance of SerfProcess.
262 263 264 265 266 267 268 |
# File 'lib/droonga/serf.rb', line 262 def initialize(loop, serf, command, *) @loop = loop @serf = serf @command = command @options = @pid = nil end |
Instance Method Details
#run_once ⇒ Object
293 294 295 296 297 298 299 300 |
# File 'lib/droonga/serf.rb', line 293 def run_once stdout, stderror, status = Open3.capture3(@serf, @command, *@options, :pgroup => true) { :result => stdout, :error => stderror, :status => status, } end |
#running? ⇒ Boolean
289 290 291 |
# File 'lib/droonga/serf.rb', line 289 def running? not @pid.nil? end |
#start ⇒ Object
270 271 272 273 274 275 276 277 278 279 |
# File 'lib/droonga/serf.rb', line 270 def start capture_output do |output_write, error_write| env = {} = { :out => output_write, :err => error_write, } @pid = spawn(env, @serf, @command, *@options, ) end end |
#stop ⇒ Object
281 282 283 284 285 286 287 |
# File 'lib/droonga/serf.rb', line 281 def stop return if @pid.nil? Process.waitpid(@pid) @output_io.close @error_io.close @pid = nil end |