Class: Foreman::Export::Upstart

Inherits:
Base
  • Object
show all
Defined in:
lib/foreman/export/upstart.rb

Instance Attribute Summary

Attributes inherited from Base

#engine, #formation, #location, #options, #port

Instance Method Summary collapse

Methods inherited from Base

#app, #initialize, #log, procfile, #run, #template, #user

Constructor Details

This class inherits a constructor from Foreman::Export::Base

Instance Method Details

#exportObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/foreman/export/upstart.rb', line 6

def export
  super

  master_file = "#{app}.conf"

  clean File.join(location, master_file)
  write_template master_template, master_file, binding

  engine.each_process do |name, process|
    process_master_file = "#{app}-#{name}.conf"
    process_file = "#{app}-#{name}-%s.conf"

    Dir[
      File.join(location, process_master_file),
      File.join(location, process_file % "*")
    ].each { |f| clean(f) }

    next if engine.formation[name] < 1
    write_template process_master_template, process_master_file, binding

    1.upto(engine.formation[name]) do |num|
      port = engine.port_for(process, num)
      write_template process_template, process_file % num, binding
    end
  end
end