This commit is contained in:
David Dollar
2010-06-09 11:51:10 -04:00
parent 2ecbf8d06d
commit 675ad2630d
4 changed files with 23 additions and 13 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
require "rubygems"
require "rake" require "rake"
require "rspec"
require "rspec/core/rake_task" require "rspec/core/rake_task"
$:.unshift File.expand_path("../lib", __FILE__) $:.unshift File.expand_path("../lib", __FILE__)
+17 -7
View File
@@ -34,23 +34,33 @@ class Foreman::Engine
run_loop run_loop
end end
def execute(name)
run(processes[name], false)
end
private ###################################################################### private ######################################################################
def fork(process) def fork(process)
pid = Process.fork do pid = Process.fork do
proctitle "ruby: foreman #{process.name}" run(process)
Dir.chdir directory do
FileUtils.mkdir_p "log"
system "#{process.command} >>log/#{process.name}.log 2>&1"
exit $?.exitstatus || 255
end
end end
info "started with pid #{pid}", process info "started with pid #{pid}", process
running_processes[pid] = process running_processes[pid] = process
end end
def run(process, log_to_file=true)
proctitle "ruby: foreman #{process.name}"
Dir.chdir directory do
FileUtils.mkdir_p "log"
command = process.command
command << " >>log/#{process.name}.log 2>&1" if log_to_file
system command
exit $?.exitstatus || 255
end
end
def kill_and_exit(signal="TERM") def kill_and_exit(signal="TERM")
info "termination requested" info "termination requested"
running_processes.each do |pid, process| running_processes.each do |pid, process|
+2 -4
View File
@@ -5,9 +5,7 @@ describe "Foreman::CLI" do
subject { Foreman::CLI.new } subject { Foreman::CLI.new }
describe "start" do describe "start" do
#let(:engine) { stub_engine } describe "with a non-existent Procfile" do
describe "with a non-existent Procifile" do
it "prints an error" do it "prints an error" do
mock_error(subject, "Procfile does not exist.") do mock_error(subject, "Procfile does not exist.") do
dont_allow.instance_of(Foreman::Engine).start dont_allow.instance_of(Foreman::Engine).start
@@ -28,7 +26,7 @@ describe "Foreman::CLI" do
end end
describe "export" do describe "export" do
describe "with a non-existent Procifile" do describe "with a non-existent Procfile" do
it "prints an error" do it "prints an error" do
mock_error(subject, "Procfile does not exist.") do mock_error(subject, "Procfile does not exist.") do
dont_allow.instance_of(Foreman::Engine).export dont_allow.instance_of(Foreman::Engine).export
+3 -1
View File
@@ -1,5 +1,7 @@
require "fakefs/spec_helpers" require "rubygems"
require "rspec" require "rspec"
require "fakefs/safe"
require "fakefs/spec_helpers"
$:.unshift "lib" $:.unshift "lib"