class Foreman::Export::MirApp

Public Instance Methods

export() click to toggle source
Calls superclass method
# File lib/foreman/export/mir_app.rb, line 15
def export
  super

  engine.each_process do |name, process|
    1.upto(engine.formation[name]) do |num|
      proc_name = "#{app}-#{name}-#{num}"
      port      = engine.port_for(process, num)
      env       = engine.env.merge("PORT" => port)
      cmd       = process.command

      create_directory(proc_name)
      create_directory("#{proc_name}/env")
      create_directory("#{proc_name}/log")

      say "creating: #{log}/#{proc_name}"
      FileUtils.mkdir_p("#{log}/#{proc_name}")

      say "writing: #{log}/#{proc_name}/config"
      config = ERB.new(export_template('mir_app/log_config.erb'), nil, '-').result(binding)
      File.open("#{log}/#{proc_name}/config", "w") { |f| f.puts(config) }

      write_template('mir_app/run.erb', "#{proc_name}/run", binding)
      chmod(0755, "#{proc_name}/run")

      write_template('mir_app/log.erb', "#{proc_name}/log/run", binding)
      chmod(0755, "#{proc_name}/log/run")

      engine.env.each do |key, value|
        write_file("#{proc_name}/env/#{key}", value)
      end
    end
  end
end
export_template(name, file=nil, template_root=nil) click to toggle source
# File lib/foreman/export/mir_app.rb, line 9
def export_template(name, file=nil, template_root=nil)
  name_without_first = name.split("/")[1..-1].join("/")
  tpl = File.expand_path("../../../../data/export/#{name}", __FILE__)
  File.read(tpl)
end