clean up exports
This commit is contained in:
1 parent
d199ef2b4d
commit
e5a8c38da6
4 files changed
+10
-10
No files matched your search
@@ -71,6 +71,12 @@ class Foreman::Engine
|
|||||||
watch_for_termination
|
watch_for_termination
|
||||||
end
|
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 ######################################################################
|
private ######################################################################
|
||||||
|
|
||||||
def fork(process)
|
def fork(process)
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ private ######################################################################
|
|||||||
File.read(File.expand_path("../../../../export/#{name}", __FILE__))
|
File.read(File.expand_path("../../../../export/#{name}", __FILE__))
|
||||||
end
|
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)
|
def write_file(filename, contents)
|
||||||
say "writing: #{filename}"
|
say "writing: #{filename}"
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Foreman::Export::Inittab < Foreman::Export::Base
|
|||||||
user = options[:user] || app
|
user = options[:user] || app
|
||||||
log_root = options[:log] || "/var/log/#{app}"
|
log_root = options[:log] || "/var/log/#{app}"
|
||||||
|
|
||||||
concurrency = parse_concurrency(options[:concurrency])
|
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
|
||||||
|
|
||||||
inittab = []
|
inittab = []
|
||||||
inittab << "# ----- foreman #{app} processes -----"
|
inittab << "# ----- foreman #{app} processes -----"
|
||||||
@@ -15,7 +15,7 @@ class Foreman::Export::Inittab < Foreman::Export::Base
|
|||||||
engine.processes.values.inject(1) do |index, process|
|
engine.processes.values.inject(1) do |index, process|
|
||||||
1.upto(concurrency[process.name]) do |num|
|
1.upto(concurrency[process.name]) do |num|
|
||||||
id = app.slice(0, 2).upcase + sprintf("%02d", index)
|
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'"
|
inittab << "#{id}:4:respawn:/bin/su - #{user} -c 'PORT=#{port} #{process.command} >> #{log_root}/#{process.name}-#{num}.log 2>&1'"
|
||||||
index += 1
|
index += 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
|
|||||||
FileUtils.rm(file)
|
FileUtils.rm(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
concurrency = parse_concurrency(options[:concurrency])
|
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
|
||||||
|
|
||||||
master_template = export_template("upstart/master.conf.erb")
|
master_template = export_template("upstart/master.conf.erb")
|
||||||
master_config = ERB.new(master_template).result(binding)
|
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
|
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
|
||||||
|
|
||||||
1.upto(concurrency[process.name]) do |num|
|
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)
|
process_config = ERB.new(process_template).result(binding)
|
||||||
write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
|
write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user