Class: Droonga::Command::DroongaEngine::ServiceRunner

Inherits:
Object
  • Object
show all
Includes:
Deferrable, Loggable
Defined in:
lib/droonga/command/droonga_engine.rb

Instance Method Summary collapse

Methods included from Deferrable

#wait_until_ready

Constructor Details

#initialize(raw_loop, configuration) ⇒ ServiceRunner

Returns a new instance of ServiceRunner.



675
676
677
678
679
# File 'lib/droonga/command/droonga_engine.rb', line 675

def initialize(raw_loop, configuration)
  @raw_loop = raw_loop
  @configuration = configuration
  @success = false
end

Instance Method Details

#refresh_self_referenceObject



727
728
729
# File 'lib/droonga/command/droonga_engine.rb', line 727

def refresh_self_reference
  @supervisor.refresh_self_reference
end

#runObject



681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/droonga/command/droonga_engine.rb', line 681

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_service_command_line,
  ]
  options = {
    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, options)
  control_write_in.close
  control_read_out.close
  @supervisor = create_process_supervisor(control_read_in,
                                          control_write_out)
  @supervisor.start
end

#stop_gracefullyObject



711
712
713
714
715
# File 'lib/droonga/command/droonga_engine.rb', line 711

def stop_gracefully
  logger.trace("stop_gracefully: start")
  @supervisor.stop_gracefully
  logger.trace("stop_gracefully: done")
end

#stop_immediatelyObject



717
718
719
720
721
# File 'lib/droonga/command/droonga_engine.rb', line 717

def stop_immediately
  logger.trace("stop_immediately: start")
  @supervisor.stop_immediately
  logger.trace("stop_immediately: done")
end

#success?Boolean

Returns:

  • (Boolean)


723
724
725
# File 'lib/droonga/command/droonga_engine.rb', line 723

def success?
  @success
end