fix supervisord export for environments containing commas

This commit is contained in:
Raphael Randschau
2012-04-20 09:11:25 +02:00
parent 93cdc31be0
commit dbda63263b
3 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ engine.procfile.entries.each do |process|
1.upto(self.concurrency[process.name]) do |num|
port = engine.port_for(process, num, self.port)
name = if (conc > 1); "#{process.name}-#{num}" else process.name; end
environment = (engine.environment.map{ |var,env| "#{var.upcase}=#{env}" } + ["PORT=#{port}"])
environment = (engine.environment.map{ |var,env| "#{var.upcase}=#{wrap_environment env}" } + ["PORT=#{port}"])
app_name = "#{app}-#{name}"
app_names << app_name
%>
+8
View File
@@ -23,4 +23,12 @@ class Foreman::Export::Supervisord < Foreman::Export::Base
write_file "#{location}/#{app}.conf", app_config
end
def wrap_environment env
if env.index(',').nil?
env
else
"\"#{env}\""
end
end
end
+10
View File
@@ -72,4 +72,14 @@ describe Foreman::Export::Supervisord, :fakefs do
end
end
context "environment export" do
it "returns the original environment if it contains no comma" do
supervisord.wrap_environment("production").should == "production"
end
it "wrapps the original environment with quotes if it contains a comma" do
supervisord.wrap_environment("slowqueue,fastqueue").should == '"slowqueue,fastqueue"'
end
end
end