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

View File

@@ -1,5 +1,5 @@
require "rubygems"
require "rake"
require "rspec"
require "rspec/core/rake_task"
$:.unshift File.expand_path("../lib", __FILE__)

View File

@@ -34,23 +34,33 @@ class Foreman::Engine
run_loop
end
def execute(name)
run(processes[name], false)
end
private ######################################################################
def fork(process)
pid = Process.fork do
proctitle "ruby: foreman #{process.name}"
Dir.chdir directory do
FileUtils.mkdir_p "log"
system "#{process.command} >>log/#{process.name}.log 2>&1"
exit $?.exitstatus || 255
end
run(process)
end
info "started with pid #{pid}", process
running_processes[pid] = process
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")
info "termination requested"
running_processes.each do |pid, process|

View File

@@ -5,9 +5,7 @@ describe "Foreman::CLI" do
subject { Foreman::CLI.new }
describe "start" do
#let(:engine) { stub_engine }
describe "with a non-existent Procifile" do
describe "with a non-existent Procfile" do
it "prints an error" do
mock_error(subject, "Procfile does not exist.") do
dont_allow.instance_of(Foreman::Engine).start
@@ -28,7 +26,7 @@ describe "Foreman::CLI" do
end
describe "export" do
describe "with a non-existent Procifile" do
describe "with a non-existent Procfile" do
it "prints an error" do
mock_error(subject, "Procfile does not exist.") do
dont_allow.instance_of(Foreman::Engine).export

View File

@@ -1,5 +1,7 @@
require "fakefs/spec_helpers"
require "rubygems"
require "rspec"
require "fakefs/safe"
require "fakefs/spec_helpers"
$:.unshift "lib"