change to Pstypes

This commit is contained in:
David Dollar
2010-10-15 15:50:40 -07:00
parent d41a8726bd
commit 8446528f5a
6 changed files with 44 additions and 44 deletions
+10 -10
View File
@@ -5,7 +5,7 @@ require "thor"
class Foreman::CLI < Thor
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: ./Procfile"
class_option :pstypes, :type => :string, :aliases => "-f", :desc => "Default: Pstypes"
desc "start [PROCESS]", "Start the application, or a specific process"
@@ -14,7 +14,7 @@ class Foreman::CLI < Thor
:banner => '"alpha=5,bar=3"'
def start(process=nil)
check_procfile!
check_pstypes!
if process
engine.execute(process, options)
@@ -33,7 +33,7 @@ class Foreman::CLI < Thor
:banner => '"alpha=5,bar=3"'
def export(format, location=nil)
check_procfile!
check_pstypes!
formatter = case format
when "upstart" then Foreman::Export::Upstart
@@ -49,16 +49,16 @@ class Foreman::CLI < Thor
private ######################################################################
def check_procfile!
error("Procfile does not exist.") unless File.exist?(procfile)
def check_pstypes!
error("#{pstypes} does not exist.") unless File.exist?(pstypes)
end
def engine
@engine ||= Foreman::Engine.new(procfile)
@engine ||= Foreman::Engine.new(pstypes)
end
def procfile
options[:procfile] || "./Procfile"
def pstypes
options[:pstypes] || "Pstypes"
end
private ######################################################################
@@ -68,8 +68,8 @@ private ######################################################################
exit 1
end
def procfile_exists?(procfile)
File.exist?(procfile)
def pstypes_exists?(pstypes)
File.exist?(pstypes)
end
end
+7 -7
View File
@@ -8,21 +8,21 @@ require "fileutils"
class Foreman::Engine
attr_reader :procfile
attr_reader :pstypes
attr_reader :directory
extend Term::ANSIColor
COLORS = [ cyan, yellow, green, magenta, red ]
def initialize(procfile)
@procfile = read_procfile(procfile)
@directory = File.expand_path(File.dirname(procfile))
def initialize(pstypes)
@pstypes = read_pstypes(pstypes)
@directory = File.expand_path(File.dirname(pstypes))
end
def processes
@processes ||= begin
procfile.split("\n").inject({}) do |hash, line|
pstypes.split("\n").inject({}) do |hash, line|
next if line.strip == ""
name, command = line.split(" ", 2)
process = Foreman::Process.new(name, command)
@@ -140,8 +140,8 @@ private ######################################################################
$0 = title
end
def read_procfile(procfile)
File.read(procfile)
def read_pstypes(pstypes)
File.read(pstypes)
end
def watch_for_termination