From 90b36be4c7fbfead4cff236bd3b929090176a61d Mon Sep 17 00:00:00 2001 From: Maciej Hryniszak Date: Wed, 26 Sep 2012 21:45:08 +0200 Subject: [PATCH] GH-268 Updated generation of upstart scripts to encompensate for additional ports --- data/export/upstart/process.conf.erb | 2 +- lib/foreman/export/upstart.rb | 5 ++++- spec/resources/export/upstart/app-alpha-1.conf | 2 +- spec/resources/export/upstart/app-alpha-2.conf | 2 +- spec/resources/export/upstart/app-bravo-1.conf | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/data/export/upstart/process.conf.erb b/data/export/upstart/process.conf.erb index 9eb67700..960e13e4 100644 --- a/data/export/upstart/process.conf.erb +++ b/data/export/upstart/process.conf.erb @@ -2,4 +2,4 @@ start on starting <%= app %>-<%= name %> stop on stopping <%= app %>-<%= name %> respawn -exec su - <%= user %> -c 'cd <%= engine.root %>; export PORT=<%= port %>;<% engine.env.each_pair do |var,env| %> export <%= var.upcase %>=<%= shell_quote(env) %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1' +exec su - <%= user %> -c 'cd <%= engine.root %>;<% environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= shell_quote(env) %>;<% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1' diff --git a/lib/foreman/export/upstart.rb b/lib/foreman/export/upstart.rb index 1c11e6d0..7f652b06 100644 --- a/lib/foreman/export/upstart.rb +++ b/lib/foreman/export/upstart.rb @@ -17,7 +17,10 @@ def export write_template "upstart/process_master.conf.erb", "#{app}-#{name}.conf", binding 1.upto(engine.formation[name]) do |num| - port = engine.port_for(process, num, 0) + environment = engine.env.dup + process.ports.each_with_index { |port, index| + environment[port] = engine.port_for(process, num, index).to_s + } write_template "upstart/process.conf.erb", "#{app}-#{name}-#{num}.conf", binding end end diff --git a/spec/resources/export/upstart/app-alpha-1.conf b/spec/resources/export/upstart/app-alpha-1.conf index a61d3922..f26a6d52 100644 --- a/spec/resources/export/upstart/app-alpha-1.conf +++ b/spec/resources/export/upstart/app-alpha-1.conf @@ -2,4 +2,4 @@ start on starting app-alpha stop on stopping app-alpha respawn -exec su - app -c 'cd /tmp/app; export PORT=5000; ./alpha >> /var/log/app/alpha-1.log 2>&1' +exec su - app -c 'cd /tmp/app; export PORT="5000"; ./alpha >> /var/log/app/alpha-1.log 2>&1' diff --git a/spec/resources/export/upstart/app-alpha-2.conf b/spec/resources/export/upstart/app-alpha-2.conf index 8e677b5a..ad5a988b 100644 --- a/spec/resources/export/upstart/app-alpha-2.conf +++ b/spec/resources/export/upstart/app-alpha-2.conf @@ -2,4 +2,4 @@ start on starting app-alpha stop on stopping app-alpha respawn -exec su - app -c 'cd /tmp/app; export PORT=5001; ./alpha >> /var/log/app/alpha-2.log 2>&1' +exec su - app -c 'cd /tmp/app; export PORT="5001"; ./alpha >> /var/log/app/alpha-2.log 2>&1' diff --git a/spec/resources/export/upstart/app-bravo-1.conf b/spec/resources/export/upstart/app-bravo-1.conf index 83f1e596..534ea703 100644 --- a/spec/resources/export/upstart/app-bravo-1.conf +++ b/spec/resources/export/upstart/app-bravo-1.conf @@ -2,4 +2,4 @@ start on starting app-bravo stop on stopping app-bravo respawn -exec su - app -c 'cd /tmp/app; export PORT=5100; ./bravo >> /var/log/app/bravo-1.log 2>&1' +exec su - app -c 'cd /tmp/app; export PORT="5100"; ./bravo >> /var/log/app/bravo-1.log 2>&1'