Class: Ladle::Server::ApacheDSController
- Inherits:
-
Object
- Object
- Ladle::Server::ApacheDSController
- Defined in:
- lib/ladle/server.rb
Overview
Encapsulates communication with the child ApacheDS process.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(ds_in, ds_out, server) ⇒ ApacheDSController
constructor
A new instance of ApacheDSController.
- #start ⇒ Object
- #started? ⇒ Boolean
- #stop ⇒ Object
- #watch ⇒ Object
Constructor Details
#initialize(ds_in, ds_out, server) ⇒ ApacheDSController
Returns a new instance of ApacheDSController.
275 276 277 278 279 |
# File 'lib/ladle/server.rb', line 275 def initialize(ds_in, ds_out, server) @ds_in = ds_in @ds_out = ds_out @server = server end |
Instance Method Details
#error? ⇒ Boolean
306 307 308 |
# File 'lib/ladle/server.rb', line 306 def error? @error end |
#start ⇒ Object
281 282 283 284 285 |
# File 'lib/ladle/server.rb', line 281 def start Thread.new(self) do |controller| controller.watch end end |
#started? ⇒ Boolean
302 303 304 |
# File 'lib/ladle/server.rb', line 302 def started? @started end |
#stop ⇒ Object
310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/ladle/server.rb', line 310 def stop unless @ds_in.closed? @ds_in.puts("STOP") @ds_in.flush end rescue Errno::EPIPE # ignore broken pipes when the process dies # right before sending the stop ensure @ds_in.close unless @ds_in.closed? end |
#watch ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/ladle/server.rb', line 287 def watch while ( !@ds_out.eof? && line = @ds_out.readline ) && !error? case line when /^STARTED/ @started = true when /^FATAL/ report_error(line) when /^STOPPED/ @started = false else report_error("Unexpected server process output: #{line}") end end end |