From c9411cd2b14a4269cdbeaa62c83cb23cc1348c53 Mon Sep 17 00:00:00 2001 From: David Dollar Date: Thu, 8 Dec 2011 17:18:21 -0800 Subject: [PATCH] wip --- bin/runner | 5 +++++ lib/foreman/process.rb | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 bin/runner diff --git a/bin/runner b/bin/runner new file mode 100755 index 0000000..80fabc9 --- /dev/null +++ b/bin/runner @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "command[$*][$1]" + +exec $1 2>&1 diff --git a/lib/foreman/process.rb b/lib/foreman/process.rb index fc75f32..71b8e74 100644 --- a/lib/foreman/process.rb +++ b/lib/foreman/process.rb @@ -14,8 +14,9 @@ class Foreman::Process def run(pipe, basedir, environment) Dir.chdir(basedir) do with_environment(environment) do - io = IO.popen("#{entry.command} $FOO 2>&1", "w+") + io = IO.popen(["/Users/david/Code/foreman/bin/runner", "#{entry.command}"], "w+") @pid = io.pid + trap("SIGTERM") { "got sigterm for %d" % @pid } output pipe, "started with pid %d" % @pid Thread.new do until io.eof? @@ -36,6 +37,9 @@ private pipe.puts "%s,%s" % [ name, message ] end + def replace_command + end + def with_environment(environment) old_env = ENV.each_pair.inject({}) { |h,(k,v)| h.update(k => v) } environment.each { |k,v| ENV[k] = v }