Class: Foreman::Export::UpstartUser
- Inherits:
-
Upstart
- Object
- Upstart
- Foreman::Export::UpstartUser
- Defined in:
- lib/foreman/export/upstart_user.rb
Instance Method Summary collapse
- #app ⇒ Object
- #export ⇒ Object
-
#initialize(location, engine, options = {}) ⇒ UpstartUser
constructor
A new instance of UpstartUser.
- #location ⇒ Object
- #log ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(location, engine, options = {}) ⇒ UpstartUser
Returns a new instance of UpstartUser.
5 6 7 8 9 10 11 12 13 |
# File 'lib/foreman/export/upstart_user.rb', line 5 def initialize location, engine, ={} super # what a pain in the ass # template is obviously not intended to be overriden unless @options.has_key?(:template) template = File.("../../../../data/export/upstart_user", __FILE__) @options = { :template => template }.merge(@options).freeze end end |
Instance Method Details
#app ⇒ Object
39 40 41 |
# File 'lib/foreman/export/upstart_user.rb', line 39 def app [:app] || File.basename(Dir.pwd) end |
#export ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/foreman/export/upstart_user.rb', line 15 def export super Dir["#{location}/#{app}*.conf"].each do |file| clean file end write_template "upstart/master.conf.erb", "#{app}.conf", binding engine.each_process do |name, process| next if engine.formation[name] < 1 write_template "upstart/process_master.conf.erb", "#{app}-#{name}.conf", binding 1.upto(engine.formation[name]) do |num| port = engine.port_for(process, num) write_template "upstart_user/process.conf.erb", "#{app}-#{name}-#{num}.conf", binding end end end |
#location ⇒ Object
35 36 37 |
# File 'lib/foreman/export/upstart_user.rb', line 35 def location [:location] || "/home/#{user}/.init" end |
#log ⇒ Object
43 44 45 |
# File 'lib/foreman/export/upstart_user.rb', line 43 def log [:log] || "log" end |
#user ⇒ Object
47 48 49 |
# File 'lib/foreman/export/upstart_user.rb', line 47 def user [:user] || `whoami`.strip end |