Compare commits

...

7 Commits

Author SHA1 Message Date
David Dollar
fcfa913fb0 0.30.1 2011-12-23 08:48:34 -05:00
David Dollar
fc438472f9 require thread for mutex 2011-12-23 08:48:17 -05:00
David Dollar
fc95936327 0.30.0 2011-12-22 16:34:02 -05:00
David Dollar
0c27f78d46 compatibility with ruby 1.8 2011-12-22 16:33:49 -05:00
David Dollar
356c61f471 0.29.0 2011-12-22 01:03:11 -05:00
David Dollar
dcff4da220 0.28.0.pre2 2011-12-08 17:59:40 -08:00
David Dollar
888520ee99 fix pipe error 2011-12-08 17:59:27 -08:00
5 changed files with 24 additions and 11 deletions

View File

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

View File

@@ -7,6 +7,7 @@ require "tempfile"
require "timeout"
require "term/ansicolor"
require "fileutils"
require "thread"
class Foreman::Engine
@@ -115,7 +116,7 @@ private ######################################################################
print "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "
print Term::ANSIColor.reset
print message.chomp
puts
puts ""
end
def print(message=nil)

View File

@@ -16,7 +16,7 @@ class Foreman::Process
def run(pipe, basedir, environment)
Dir.chdir(basedir) do
with_environment(environment.merge("PORT" => port.to_s)) do
run_process entry.command
run_process entry.command, pipe
end
end
end
@@ -27,9 +27,21 @@ class Foreman::Process
private
def run_process(command)
io = IO.popen([Foreman.runner, replace_command_env(command)], "w+")
@pid = io.pid
def fork_with_io(command)
io = case RUBY_VERSION
when /^1\.9\./
IO.popen([Foreman.runner, replace_command_env(command)], "w+")
when /^1\.8\./
full_command = replace_command_env(command).gsub("'", "\\'")
IO.popen("#{Foreman.runner} '#{full_command}'", "w+")
else
raise "Unknown Ruby version: #{RUBY_VERSION}"
end
[ io, io.pid ]
end
def run_process(command, pipe)
io, @pid = fork_with_io(command)
trap("SIGTERM") { "got sigterm for %d" % @pid }
output pipe, "started with pid %d" % @pid
Thread.new do

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.28.0.pre1"
VERSION = "0.30.1"
end

View File

@@ -24,8 +24,8 @@ describe "Foreman::Engine" do
describe "start" do
it "forks the processes" do
write_procfile
mock.instance_of(Foreman::Process).run_process("./alpha")
mock.instance_of(Foreman::Process).run_process("./bravo")
mock.instance_of(Foreman::Process).run_process("./alpha", is_a(IO))
mock.instance_of(Foreman::Process).run_process("./bravo", is_a(IO))
mock(subject).watch_for_output
mock(subject).watch_for_termination
subject.start
@@ -34,8 +34,8 @@ describe "Foreman::Engine" do
it "handles concurrency" do
write_procfile
engine = Foreman::Engine.new("Procfile",:concurrency => "alpha=2")
mock.instance_of(Foreman::Process).run_process("./alpha").twice
mock.instance_of(Foreman::Process).run_process("./bravo")
mock.instance_of(Foreman::Process).run_process("./alpha", is_a(IO)).twice
mock.instance_of(Foreman::Process).run_process("./bravo", is_a(IO))
mock(engine).watch_for_output
mock(engine).watch_for_termination
engine.start