Class: Droonga::Supervisor::WorkerRunner
- Inherits:
-
Object
- Object
- Droonga::Supervisor::WorkerRunner
- Includes:
- Deferrable, Loggable
- Defined in:
- lib/droonga/supervisor.rb
Instance Method Summary collapse
-
#initialize(loop, id, config) ⇒ WorkerRunner
constructor
A new instance of WorkerRunner.
- #refresh_node_reference ⇒ Object
- #start ⇒ Object
- #stop_gracefully(&block) ⇒ Object
- #stop_immediately ⇒ Object
- #success? ⇒ Boolean
Methods included from Deferrable
Constructor Details
#initialize(loop, id, config) ⇒ WorkerRunner
Returns a new instance of WorkerRunner.
102 103 104 105 106 107 |
# File 'lib/droonga/supervisor.rb', line 102 def initialize(loop, id, config) @loop = loop @id = id @config = config @stop_gracefully_callback = nil end |
Instance Method Details
#refresh_node_reference ⇒ Object
153 154 155 |
# File 'lib/droonga/supervisor.rb', line 153 def refresh_node_reference @supervisor.refresh_node_reference end |
#start ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/droonga/supervisor.rb', line 109 def start control_write_in, control_write_out = IO.pipe control_read_in, control_read_out = IO.pipe env = {} command_line = [ RbConfig.ruby, "-S", "droonga-engine-worker", "--control-read-fd", control_write_in.fileno.to_s, "--control-write-fd", control_read_out.fileno.to_s, "--job-queue-socket-path", @config.job_pusher.socket_path.to_s, "--pid-file", pid_path.to_s, "--label", @config.label, "--dataset", @config.dataset.name, "--database-path", @config.database_path.to_s, "--plugins", @config.plugins.join(","), "--internal-connection-lifetime", @config.internal_connection_lifetime.to_s, ] = { 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(&block) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/droonga/supervisor.rb', line 140 def stop_gracefully(&block) logger.trace("stop_gracefully: start") @supervisor.stop_gracefully @stop_gracefully_callback = lambda do yield if block_given? logger.trace("stop_gracefully: done") end end |
#stop_immediately ⇒ Object
149 150 151 |
# File 'lib/droonga/supervisor.rb', line 149 def stop_immediately @supervisor.stop_immediately end |
#success? ⇒ Boolean
157 158 159 |
# File 'lib/droonga/supervisor.rb', line 157 def success? @success end |