Compare commits

..

7 Commits

Author SHA1 Message Date
David Dollar
0f7eec061d Regenerated gemspec for version 0.3.2 2010-06-22 17:20:21 -04:00
David Dollar
27e53eb916 0.3.2 2010-06-22 17:20:15 -04:00
David Dollar
b123e6b3c5 change the output format 2010-06-22 17:20:01 -04:00
David Dollar
c2000484bb capture PTY::ChildExited 2010-06-22 17:19:47 -04:00
David Dollar
75f0ce4b9c Regenerated gemspec for version 0.3.1 2010-06-22 16:48:41 -04:00
David Dollar
d508d44fd2 0.3.1 2010-06-22 16:48:39 -04:00
David Dollar
35cc880d40 clean up messaging 2010-06-22 16:48:16 -04:00
3 changed files with 25 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{foreman}
s.version = "0.3.0"
s.version = "0.3.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["David Dollar"]

View File

@@ -1,6 +1,6 @@
module Foreman
VERSION = "0.3.0"
VERSION = "0.3.2"
class AppDoesNotExist < Exception; end

View File

@@ -77,16 +77,20 @@ private ######################################################################
FileUtils.mkdir_p "log"
command = process.command
PTY.spawn("#{process.command} 2>&1") do |stdin, stdout, pid|
until stdin.eof?
info stdin.gets, process
begin
PTY.spawn("#{process.command} 2>&1") do |stdin, stdout, pid|
until stdin.eof?
info stdin.gets, process
end
end
rescue PTY::ChildExited
# exited
end
end
end
def kill_and_exit(signal="TERM")
info "termination requested"
info "terminating"
running_processes.each do |pid, process|
info "killing #{process.name} in pid #{pid}"
Process.kill(signal, pid)
@@ -96,11 +100,25 @@ private ######################################################################
def info(message, process=nil)
print process.color if process
print "[#{Time.now.strftime("%H:%M:%S")}] [#{process ? process.name : "system"}] #{message.chomp}"
print "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(process)} | "
print Term::ANSIColor.reset
print message.chomp
puts
end
def longest_process_name
@longest_process_name ||= begin
longest = processes.keys.map { |name| name.length }.sort.last
longest = 6 if longest < 6 # system
longest
end
end
def pad_process_name(process)
name = process ? process.name : "system"
name.ljust(longest_process_name)
end
def print_info
info "currently running processes:"
running_processes.each do |pid, process|