From c9943d70ec545ec04bb012d5415a043197e3076b Mon Sep 17 00:00:00 2001 From: Raphael Randschau Date: Mon, 5 Mar 2012 15:48:40 +0100 Subject: [PATCH] add group support for supervisord --- data/export/supervisord/app.conf.erb | 10 ++++++++-- spec/foreman/export/supervisord_spec.rb | 4 ++-- spec/resources/export/supervisord/app-alpha-2.conf | 3 +++ spec/resources/export/supervisord/app.conf | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/data/export/supervisord/app.conf.erb b/data/export/supervisord/app.conf.erb index 6054225..439fc8f 100644 --- a/data/export/supervisord/app.conf.erb +++ b/data/export/supervisord/app.conf.erb @@ -1,12 +1,15 @@ <% +app_names = [] engine.procfile.entries.each do |process| next if (conc = self.concurrency[process.name]) < 1 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}"]) + app_name = "#{app}-#{name}" + app_names << app_name %> -[program:<%= app %>-<%= name %>] +[program:<%= app_name %>] command=<%= process.command %> autostart=true autorestart=true @@ -18,4 +21,7 @@ directory=<%= engine.directory %> environment=<%= environment.join(',') %><% end end -%> \ No newline at end of file +%> + +[group:<%= app %>] +programs:<%= app_names.join(',') %> \ No newline at end of file diff --git a/spec/foreman/export/supervisord_spec.rb b/spec/foreman/export/supervisord_spec.rb index c87d056..616b181 100644 --- a/spec/foreman/export/supervisord_spec.rb +++ b/spec/foreman/export/supervisord_spec.rb @@ -30,7 +30,7 @@ describe Foreman::Export::Supervisord, :fakefs do it "exports to the filesystem with concurrency" do supervisord.export - + File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf") end end @@ -46,7 +46,7 @@ describe Foreman::Export::Supervisord, :fakefs do it "can export with alternate template files" do supervisord.export - + File.read("/tmp/init/app.conf").should == "alternate_template\n" end end diff --git a/spec/resources/export/supervisord/app-alpha-2.conf b/spec/resources/export/supervisord/app-alpha-2.conf index c16b72f..409809d 100644 --- a/spec/resources/export/supervisord/app-alpha-2.conf +++ b/spec/resources/export/supervisord/app-alpha-2.conf @@ -19,3 +19,6 @@ stderr_logfile=/var/log/app/alpha-2-err.log user=app directory=/tmp/app environment=PORT=5001 + +[group:app] +programs:app-alpha-1,app-alpha-2 diff --git a/spec/resources/export/supervisord/app.conf b/spec/resources/export/supervisord/app.conf index efcb28e..b0b22ea 100644 --- a/spec/resources/export/supervisord/app.conf +++ b/spec/resources/export/supervisord/app.conf @@ -19,3 +19,6 @@ stderr_logfile=/var/log/app/bravo-1-err.log user=app directory=/tmp/app environment=PORT=5100 + +[group:app] +programs:app-alpha,app-bravo