Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f7eec061d | ||
|
|
27e53eb916 | ||
|
|
b123e6b3c5 | ||
|
|
c2000484bb | ||
|
|
75f0ce4b9c | ||
|
|
d508d44fd2 | ||
|
|
35cc880d40 |
@@ -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"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Foreman
|
||||
|
||||
VERSION = "0.3.0"
|
||||
VERSION = "0.3.2"
|
||||
|
||||
class AppDoesNotExist < Exception; end
|
||||
|
||||
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user