Class: Droonga::Command::DroongaEngine::ServiceRunner
- Inherits:
-
Object
- Object
- Droonga::Command::DroongaEngine::ServiceRunner
- Defined in:
- lib/droonga/command/droonga_engine.rb
Instance Method Summary collapse
-
#initialize(raw_loop, configuration) ⇒ ServiceRunner
constructor
A new instance of ServiceRunner.
- #on_failure=(callback) ⇒ Object
- #on_ready=(callback) ⇒ Object
- #run ⇒ Object
- #stop_gracefully ⇒ Object
- #stop_immediately ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(raw_loop, configuration) ⇒ ServiceRunner
Returns a new instance of ServiceRunner.
402 403 404 405 406 407 408 |
# File 'lib/droonga/command/droonga_engine.rb', line 402 def initialize(raw_loop, configuration) @raw_loop = raw_loop @configuration = configuration @success = false @on_ready = nil @on_failure = nil end |
Instance Method Details
#on_failure=(callback) ⇒ Object
414 415 416 |
# File 'lib/droonga/command/droonga_engine.rb', line 414 def on_failure=(callback) @on_failure = callback end |
#on_ready=(callback) ⇒ Object
410 411 412 |
# File 'lib/droonga/command/droonga_engine.rb', line 410 def on_ready=(callback) @on_ready = callback end |
#run ⇒ Object
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/droonga/command/droonga_engine.rb', line 418 def run control_write_in, control_write_out = IO.pipe control_read_in, control_read_out = IO.pipe listen_fd = @configuration.listen_socket.fileno heartbeat_fd = @configuration.heartbeat_socket.fileno env = {} command_line = [ RbConfig.ruby, "-S", "droonga-engine-service", "--listen-fd", listen_fd.to_s, "--heartbeat-fd", heartbeat_fd.to_s, "--control-read-fd", control_write_in.fileno.to_s, "--control-write-fd", control_read_out.fileno.to_s, *@configuration.to_command_line, ] = { listen_fd => listen_fd, heartbeat_fd => heartbeat_fd, control_write_in => control_write_in, control_read_out => control_read_out, } @pid = spawn(env, *command_line, ) control_write_in.close control_read_out.close @supervisor = create_process_supervisor(control_read_in, control_write_out) @supervisor.start end |
#stop_gracefully ⇒ Object
448 449 450 |
# File 'lib/droonga/command/droonga_engine.rb', line 448 def stop_gracefully @supervisor.stop_gracefully end |
#stop_immediately ⇒ Object
452 453 454 |
# File 'lib/droonga/command/droonga_engine.rb', line 452 def stop_immediately @supervisor.stop_immediately end |
#success? ⇒ Boolean
456 457 458 |
# File 'lib/droonga/command/droonga_engine.rb', line 456 def success? @success end |