Class: Foreman::Export::Daemon

Inherits:
Base
  • Object
show all
Defined in:
lib/foreman/export/daemon.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
# File 'lib/foreman/export/daemon.rb', line 6

def export
  super

  (Dir["#{location}/#{app}-*.conf"] << "#{location}/#{app}.conf").each do |file|
    clean file
  end

  write_template "daemon/master.conf.erb", "#{app}.conf", binding

  engine.each_process do |name, process|
    next if engine.formation[name] < 1
    write_template "daemon/process_master.conf.erb", "#{app}-#{name}.conf", binding

    1.upto(engine.formation[name]) do |num|
      port = engine.port_for(process, num)
      arguments = process.command.split(" ")
      executable = arguments.slice!(0)
      arguments = arguments.size > 0 ? " -- #{arguments.join(' ')}" : ""
      write_template "daemon/process.conf.erb", "#{app}-#{name}-#{num}.conf", binding
    end
  end
end