Class: Foreman::Export::Runit

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

Constant Summary collapse

ENV_VARIABLE_REGEX =
/([a-zA-Z_]+[a-zA-Z0-9_]*)=(\S+)/

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


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

def export
  super

  engine.each_process do |name, process|
    1.upto(engine.formation[name]) do |num|
      process_directory = "#{app}-#{name}-#{num}"

      create_directory process_directory
      create_directory "#{process_directory}/env"
      create_directory "#{process_directory}/log"

      write_template "runit/run.erb", "#{process_directory}/run", binding
      chmod 0755, "#{process_directory}/run"

      port = engine.port_for(process, num)
      engine.env.merge("PORT" => port.to_s).each do |key, value|
        write_file "#{process_directory}/env/#{key}", value
      end

      write_template "runit/log/run.erb", "#{process_directory}/log/run", binding
      chmod 0755, "#{process_directory}/log/run"
    end
  end

end