Compare commits

...
8 Commits
13 changed files with 77 additions and 5 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
foreman (0.13.1) foreman (0.15.0)
term-ansicolor (~> 1.0.5) term-ansicolor (~> 1.0.5)
thor (>= 0.13.6) thor (>= 0.13.6)
+2
View File
@@ -2,6 +2,8 @@
## Manual ## Manual
http://blog.daviddollar.org/2011/05/06/introducing-foreman.html
See the [man page](http://ddollar.github.com/foreman) for usage. See the [man page](http://ddollar.github.com/foreman) for usage.
## License ## License
+1 -1
View File
@@ -3,4 +3,4 @@ stop on stopping <%= app %>-<%= process.name %>
respawn respawn
chdir <%= engine.directory %> chdir <%= engine.directory %>
exec su - <%= user %> -c 'export PORT=<%= port %>; <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1' exec su <%= user %> -c 'export PORT=<%= port %>; <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1'
+2 -2
View File
@@ -57,7 +57,7 @@ class Foreman::Engine
end end
trap("TERM") { puts "SIGTERM received"; kill_all("TERM") } trap("TERM") { puts "SIGTERM received"; kill_all("TERM") }
trap("INT") { puts "SIGINT received"; kill_all("INT") } trap("INT") { puts "SIGINT received"; kill_all("TERM") }
watch_for_termination watch_for_termination
end end
@@ -66,7 +66,7 @@ class Foreman::Engine
fork processes[name], options fork processes[name], options
trap("TERM") { puts "SIGTERM received"; kill_all("TERM") } trap("TERM") { puts "SIGTERM received"; kill_all("TERM") }
trap("INT") { puts "SIGINT received"; kill_all("INT") } trap("INT") { puts "SIGINT received"; kill_all("TERM") }
watch_for_termination watch_for_termination
end end
+1 -1
View File
@@ -1,5 +1,5 @@
module Foreman module Foreman
VERSION = "0.13.1" VERSION = "0.15.0"
end end
+19
View File
@@ -1,2 +1,21 @@
require "spec_helper" require "spec_helper"
require "foreman/export/upstart" require "foreman/export/upstart"
describe Foreman::Export::Upstart do
let(:engine) { Foreman::Engine.new(write_procfile) }
let(:upstart) { Foreman::Export::Upstart.new(engine) }
before(:each) { load_export_templates_into_fakefs("upstart") }
before(:each) { stub(upstart).say }
it "exports to the filesystem" do
upstart.export("/tmp/init")
File.read("/tmp/init/foreman.conf").should == example_export_file("upstart/foreman.conf")
File.read("/tmp/init/foreman-alpha.conf").should == example_export_file("upstart/foreman-alpha.conf")
File.read("/tmp/init/foreman-alpha-1.conf").should == example_export_file("upstart/foreman-alpha-1.conf")
File.read("/tmp/init/foreman-alpha-2.conf").should == example_export_file("upstart/foreman-alpha-2.conf")
File.read("/tmp/init/foreman-bravo.conf").should == example_export_file("upstart/foreman.bravo.conf")
File.read("/tmp/init/foreman-bravo-1.conf").should == example_export_file("upstart/foreman-bravo-1.conf")
end
end
@@ -0,0 +1,6 @@
start on starting foreman-alpha
stop on stopping foreman-alpha
respawn
chdir /Users/david/Code/foreman
exec su foreman -c 'export PORT=5000; ./alpha >> /var/log/foreman/alpha-1.log 2>&1'
@@ -0,0 +1,6 @@
start on starting foreman-alpha
stop on stopping foreman-alpha
respawn
chdir /Users/david/Code/foreman
exec su foreman -c 'export PORT=5001; ./alpha >> /var/log/foreman/alpha-2.log 2>&1'
@@ -0,0 +1,2 @@
start on starting foreman
stop on stopping foreman
@@ -0,0 +1,6 @@
start on starting foreman-bravo
stop on stopping foreman-bravo
respawn
chdir /Users/david/Code/foreman
exec su foreman -c 'export PORT=5100; ./bravo >> /var/log/foreman/bravo-1.log 2>&1'
@@ -0,0 +1,2 @@
start on starting foreman
stop on stopping foreman
@@ -0,0 +1,8 @@
pre-start script
bash << "EOF"
mkdir -p /var/log/foreman
chown -R foreman /var/log/foreman
EOF
end script
+21
View File
@@ -29,6 +29,27 @@ def write_procfile(procfile="Procfile")
file.puts "alpha: ./alpha" file.puts "alpha: ./alpha"
file.puts "bravo: ./bravo" file.puts "bravo: ./bravo"
end end
File.expand_path(procfile)
end
def load_export_templates_into_fakefs(type)
FakeFS.deactivate!
files = Dir[File.expand_path("../../data/export/#{type}/**", __FILE__)].inject({}) do |hash, file|
hash.update(file => File.read(file))
end
FakeFS.activate!
files.each do |filename, contents|
File.open(filename, "w") do |f|
f.puts contents
end
end
end
def example_export_file(filename)
FakeFS.deactivate!
data = File.read(File.expand_path("../resources/export/#{filename}", __FILE__))
FakeFS.activate!
data
end end
Rspec.configure do |config| Rspec.configure do |config|