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.



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

Returns:

  • (Boolean)


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

def error?
  @error
end

#startObject



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

Returns:

  • (Boolean)


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

def started?
  @started
end

#stopObject



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

#watchObject



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