Method: Foreman::Engine#initialize

Defined in:
lib/foreman/engine.rb

#initialize(options = {}) ⇒ Engine

Create an Engine for running processes

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :formation (String) — default: all=1

    The process formation to use

  • :port (Fixnum) — default: 5000

    The base port to assign to processes

  • :root (String) — default: Dir.pwd

    The root directory from which to run processes



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/foreman/engine.rb', line 27

def initialize(options={})
  @options = options.dup

  @options[:formation] ||= "all=1"
  @options[:timeout] ||= 5

  @env       = {}
  @mutex     = Mutex.new
  @names     = {}
  @processes = []
  @running   = {}
  @readers   = {}
  @shutdown  = false

  # Self-pipe for deferred signal-handling (ala djb: http://cr.yp.to/docs/selfpipe.html)
  reader, writer       = create_pipe
  reader.close_on_exec = true if reader.respond_to?(:close_on_exec)
  writer.close_on_exec = true if writer.respond_to?(:close_on_exec)
  @selfpipe            = { :reader => reader, :writer => writer }

  # Set up a global signal queue
  # http://blog.rubybestpractices.com/posts/ewong/016-Implementing-Signal-Handlers.html
  Thread.main[:signal_queue] = []
end