clean up exports

This commit is contained in:
David Dollar
2010-07-20 16:19:40 -07:00
parent d199ef2b4d
commit e5a8c38da6
4 changed files with 10 additions and 10 deletions

View File

@@ -71,6 +71,12 @@ class Foreman::Engine
watch_for_termination
end
def port_for(process, num, base_port=nil)
base_port ||= 5000
offset = processes.keys.sort.index(process.name) * 100
base_port.to_i + offset + num - 1
end
private ######################################################################
def fork(process)

View File

@@ -27,12 +27,6 @@ private ######################################################################
File.read(File.expand_path("../../../../export/#{name}", __FILE__))
end
def port_for(base_port, app, num)
base_port ||= 5000
offset = engine.processes.keys.sort.index(app) * 100
base_port.to_i + offset + num - 1
end
def write_file(filename, contents)
say "writing: #{filename}"

View File

@@ -7,7 +7,7 @@ class Foreman::Export::Inittab < Foreman::Export::Base
user = options[:user] || app
log_root = options[:log] || "/var/log/#{app}"
concurrency = parse_concurrency(options[:concurrency])
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
inittab = []
inittab << "# ----- foreman #{app} processes -----"
@@ -15,7 +15,7 @@ class Foreman::Export::Inittab < Foreman::Export::Base
engine.processes.values.inject(1) do |index, process|
1.upto(concurrency[process.name]) do |num|
id = app.slice(0, 2).upcase + sprintf("%02d", index)
port = port_for(options[:port], process.name, num)
port = engine.port_for(process, num, options[:port])
inittab << "#{id}:4:respawn:/bin/su - #{user} -c 'PORT=#{port} #{process.command} >> #{log_root}/#{process.name}-#{num}.log 2>&1'"
index += 1
end

View File

@@ -17,7 +17,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
FileUtils.rm(file)
end
concurrency = parse_concurrency(options[:concurrency])
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
master_template = export_template("upstart/master.conf.erb")
master_config = ERB.new(master_template).result(binding)
@@ -31,7 +31,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
1.upto(concurrency[process.name]) do |num|
port = port_for(options[:port], process.name, num)
port = engine.port_for(process, num, options[:port])
process_config = ERB.new(process_template).result(binding)
write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
end