rename supervisord base template to app
add supervisord stub
This commit is contained in:
1 parent
8cb58b8517
commit
1127551369
5 files changed
+105
-18
No files matched your search
+16
-14
@@ -13,28 +13,30 @@ GEM
|
|||||||
mime-types
|
mime-types
|
||||||
xml-simple
|
xml-simple
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
crack (0.1.8)
|
crack (0.3.1)
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
fakefs (0.3.2)
|
fakefs (0.3.2)
|
||||||
hpricot (0.8.6)
|
hpricot (0.8.6)
|
||||||
hpricot (0.8.6-java)
|
hpricot (0.8.6-java)
|
||||||
mime-types (1.16)
|
mime-types (1.17.2)
|
||||||
multi_json (1.0.4)
|
multi_json (1.1.0)
|
||||||
mustache (0.11.2)
|
mustache (0.99.4)
|
||||||
parka (0.6.2)
|
parka (0.8.0)
|
||||||
crack
|
crack (~> 0.3.0)
|
||||||
rest-client
|
psych (~> 1.2.1)
|
||||||
thor
|
rest-client (~> 1.6.7)
|
||||||
|
thor (~> 0.14.6)
|
||||||
posix-spawn (0.3.6)
|
posix-spawn (0.3.6)
|
||||||
|
psych (1.2.2)
|
||||||
rake (0.9.2.2)
|
rake (0.9.2.2)
|
||||||
rdiscount (1.6.5)
|
rdiscount (1.6.8)
|
||||||
rest-client (1.6.1)
|
rest-client (1.6.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
ronn (0.7.3)
|
ronn (0.7.3)
|
||||||
hpricot (>= 0.8.2)
|
hpricot (>= 0.8.2)
|
||||||
mustache (>= 0.7.0)
|
mustache (>= 0.7.0)
|
||||||
rdiscount (>= 1.5.8)
|
rdiscount (>= 1.5.8)
|
||||||
rr (1.0.2)
|
rr (1.0.4)
|
||||||
rspec (2.8.0)
|
rspec (2.8.0)
|
||||||
rspec-core (~> 2.8.0)
|
rspec-core (~> 2.8.0)
|
||||||
rspec-expectations (~> 2.8.0)
|
rspec-expectations (~> 2.8.0)
|
||||||
@@ -43,14 +45,14 @@ GEM
|
|||||||
rspec-expectations (2.8.0)
|
rspec-expectations (2.8.0)
|
||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-mocks (2.8.0)
|
rspec-mocks (2.8.0)
|
||||||
simplecov (0.5.4)
|
simplecov (0.6.0)
|
||||||
multi_json (~> 1.0.3)
|
multi_json (~> 1.0)
|
||||||
simplecov-html (~> 0.5.3)
|
simplecov-html (~> 0.5.3)
|
||||||
simplecov-html (0.5.3)
|
simplecov-html (0.5.3)
|
||||||
term-ansicolor (1.0.7)
|
term-ansicolor (1.0.7)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
win32console (1.3.0-x86-mingw32)
|
win32console (1.3.0-x86-mingw32)
|
||||||
xml-simple (1.0.15)
|
xml-simple (1.1.1)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
java
|
java
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ stdout_logfile=<%= log_root %>/<%=process.name%>-<%=num%>.log
|
|||||||
stderr_logfile=<%= log_root %>/<%=process.name%>-<%=num%>err.log
|
stderr_logfile=<%= log_root %>/<%=process.name%>-<%=num%>err.log
|
||||||
user=<%= user %>
|
user=<%= user %>
|
||||||
directory=<%= engine.directory %>
|
directory=<%= engine.directory %>
|
||||||
environment=<% engine.environment.each_pair { |var,env| "#{var.upcase}=#{env}" }.join(',') %>,<%= "PORT=#{port}" %>
|
environment=<% (engine.environment.each_pair { |var,env| "#{var.upcase}=#{env}" }.to_a + ["PORT=#{port}"]).join(',') %>
|
||||||
<%
|
<%
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -18,9 +18,9 @@ class Foreman::Export::Supervisord < Foreman::Export::Base
|
|||||||
FileUtils.rm(file)
|
FileUtils.rm(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
master_template = export_template("supervisord", "master.conf.erb", template_root)
|
app_template = export_template("supervisord", "app.conf.erb", template_root)
|
||||||
master_config = ERB.new(master_template).result(binding)
|
app_config = ERB.new(app_template).result(binding)
|
||||||
write_file "#{location}/#{app}.conf", master_config
|
write_file "#{location}/#{app}.conf", app_config
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
require "foreman/engine"
|
||||||
|
require "foreman/export/supervisord"
|
||||||
|
require "tmpdir"
|
||||||
|
|
||||||
|
describe Foreman::Export::Supervisord, :fakefs do
|
||||||
|
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
||||||
|
let(:engine) { Foreman::Engine.new(procfile) }
|
||||||
|
let(:options) { Hash.new }
|
||||||
|
let(:supervisord) { Foreman::Export::Supervisord.new("/tmp/init", engine, options) }
|
||||||
|
|
||||||
|
before(:each) { load_export_templates_into_fakefs("supervisord") }
|
||||||
|
before(:each) { stub(supervisord).say }
|
||||||
|
|
||||||
|
it "exports to the filesystem" do
|
||||||
|
supervisord.export
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "cleans up if exporting into an existing dir" do
|
||||||
|
mock(FileUtils).rm("/tmp/init/app.conf")
|
||||||
|
|
||||||
|
supervisord.export
|
||||||
|
supervisord.export
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with concurrency" do
|
||||||
|
let(:options) { Hash[:concurrency => "alpha=2"] }
|
||||||
|
|
||||||
|
it "exports to the filesystem with concurrency" do
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with alternate templates" do
|
||||||
|
let(:template_root) { "/tmp/alternate" }
|
||||||
|
let(:upstart) { Foreman::Export::Upstart.new("/tmp/init", engine, :template => template_root) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
FileUtils.mkdir_p template_root
|
||||||
|
File.open("#{template_root}/master.conf.erb", "w") { |f| f.puts "alternate_template" }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can export with alternate template files" do
|
||||||
|
upstart.export
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == "alternate_template\n"
|
||||||
|
pendign
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with alternate templates from home dir" do
|
||||||
|
let(:default_template_root) {File.expand_path("#{ENV['HOME']}/.foreman/templates")}
|
||||||
|
|
||||||
|
before do
|
||||||
|
ENV['_FOREMAN_SPEC_HOME'] = ENV['HOME']
|
||||||
|
ENV['HOME'] = "/home/appuser"
|
||||||
|
FileUtils.mkdir_p default_template_root
|
||||||
|
File.open("#{default_template_root}/master.conf.erb", "w") { |f| f.puts "default_alternate_template" }
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
ENV['HOME'] = ENV.delete('_FOREMAN_SPEC_HOME')
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can export with alternate template files" do
|
||||||
|
upstart.export
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[program:app-alpha]
|
||||||
|
command=./alpha
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/alpha-1.log
|
||||||
|
stderr_logfile=/var/log/app/alpha-1err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=PORT=5000
|
||||||
Reference in new issue
Block a user