Compare commits

..

5 Commits

Author SHA1 Message Date
David Dollar
180f63624e 0.14.0 2011-05-11 21:42:12 -04:00
David Dollar
13fd1188ad add export specs 2011-05-11 21:41:56 -04:00
David Dollar
92c2b15785 Merge pull request #18 from clifff/master
Upstart process su'ing into wrong dir
2011-05-11 18:04:18 -07:00
clifff
4a2d7565b7 Cleaner version of ensuring upstart process su goes to the correct dir 2011-05-11 18:51:31 -04:00
clifff
49720e0458 Moved upstart process 'chdir' into after su into user, since that will change dir to user home 2011-05-11 18:23:38 -04:00
11 changed files with 73 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.13.1)
foreman (0.14.0)
term-ansicolor (~> 1.0.5)
thor (>= 0.13.6)

View File

@@ -3,4 +3,4 @@ stop on stopping <%= app %>-<%= process.name %>
respawn
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'

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.13.1"
VERSION = "0.14.0"
end

View File

@@ -1,2 +1,21 @@
require "spec_helper"
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

View File

@@ -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'

View File

@@ -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'

View File

@@ -0,0 +1,2 @@
start on starting foreman
stop on stopping foreman

View File

@@ -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'

View File

@@ -0,0 +1,2 @@
start on starting foreman
stop on stopping foreman

View File

@@ -0,0 +1,8 @@
pre-start script
bash << "EOF"
mkdir -p /var/log/foreman
chown -R foreman /var/log/foreman
EOF
end script

View File

@@ -29,6 +29,27 @@ def write_procfile(procfile="Procfile")
file.puts "alpha: ./alpha"
file.puts "bravo: ./bravo"
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
Rspec.configure do |config|