windows support

This commit is contained in:
David Dollar
2012-01-22 20:33:14 -05:00
parent 4ad49cb058
commit f60c4cb767
7 changed files with 37 additions and 12 deletions
+8 -1
View File
@@ -14,5 +14,12 @@ module Foreman
File.expand_path("../../bin/runner", __FILE__)
end
end
def self.jruby?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
end
def self.windows?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
end
end
+2 -1
View File
@@ -88,6 +88,7 @@ private ######################################################################
def watch_for_output
Thread.new do
require "win32console" if Foreman.windows?
begin
loop do
rs, ws = IO.select(readers.values, [], [], 1)
@@ -155,7 +156,7 @@ private ######################################################################
end
def termtitle(title)
printf("\033]0;#{title}\007")
printf("\033]0;#{title}\007") unless Foreman.windows?
end
def running_processes
+2 -10
View File
@@ -26,22 +26,14 @@ class Foreman::Process
private
def jruby?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
end
def windows?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
end
def fork_with_io(command, basedir)
reader, writer = IO.pipe
command = replace_command_env(command)
pid = if windows?
pid = if Foreman.windows?
Dir.chdir(basedir) do
Process.spawn command, :out => writer, :err => writer
end
elsif jruby?
elsif Foreman.jruby?
require "posix/spawn"
POSIX::Spawn.spawn(Foreman.runner, "-d", basedir, command, {
:out => writer, :err => writer