Class: Ladle::Server::ApacheDSController

Inherits:
Object
  • Object
show all
Defined in:
lib/ladle/server.rb

Overview

Encapsulates communication with the child ApacheDS process.

Instance Method Summary collapse

Constructor Details

#initialize(ds_in, ds_out, server) ⇒ ApacheDSController

Returns a new instance of ApacheDSController.



276
277
278
279
280
# File 'lib/ladle/server.rb', line 276

def initialize(ds_in, ds_out, server)
  @ds_in = ds_in
  @ds_out = ds_out
  @server = server
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


307
308
309
# File 'lib/ladle/server.rb', line 307

def error?
  @error
end

#startObject



282
283
284
285
286
# File 'lib/ladle/server.rb', line 282

def start
  Thread.new(self) do |controller|
    controller.watch
  end
end

#started?Boolean

Returns:

  • (Boolean)


303
304
305
# File 'lib/ladle/server.rb', line 303

def started?
  @started
end

#stopObject



311
312
313
314
315
316
317
318
319
320
321
# File 'lib/ladle/server.rb', line 311

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

#watchObject



288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/ladle/server.rb', line 288

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