File: daemon.rb

package info (click to toggle)
ruby-foreman 0.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 584 kB
  • sloc: ruby: 2,020; sh: 88; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require "erb"
require "foreman/export"

class Foreman::Export::Daemon < Foreman::Export::Base

  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
end