using Psfile
This commit is contained in:
+10
-10
@@ -5,7 +5,7 @@ require "thor"
|
||||
|
||||
class Foreman::CLI < Thor
|
||||
|
||||
class_option :pstypes, :type => :string, :aliases => "-f", :desc => "Default: Pstypes"
|
||||
class_option :psfile, :type => :string, :aliases => "-f", :desc => "Default: Psfile"
|
||||
|
||||
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_pstypes!
|
||||
check_psfile!
|
||||
|
||||
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_pstypes!
|
||||
check_psfile!
|
||||
|
||||
formatter = case format
|
||||
when "upstart" then Foreman::Export::Upstart
|
||||
@@ -49,16 +49,16 @@ class Foreman::CLI < Thor
|
||||
|
||||
private ######################################################################
|
||||
|
||||
def check_pstypes!
|
||||
error("#{pstypes} does not exist.") unless File.exist?(pstypes)
|
||||
def check_psfile!
|
||||
error("#{psfile} does not exist.") unless File.exist?(psfile)
|
||||
end
|
||||
|
||||
def engine
|
||||
@engine ||= Foreman::Engine.new(pstypes)
|
||||
@engine ||= Foreman::Engine.new(psfile)
|
||||
end
|
||||
|
||||
def pstypes
|
||||
options[:pstypes] || "Pstypes"
|
||||
def psfile
|
||||
options[:psfile] || "Psfile"
|
||||
end
|
||||
|
||||
private ######################################################################
|
||||
@@ -68,8 +68,8 @@ private ######################################################################
|
||||
exit 1
|
||||
end
|
||||
|
||||
def pstypes_exists?(pstypes)
|
||||
File.exist?(pstypes)
|
||||
def psfile_exists?(psfile)
|
||||
File.exist?(psfile)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,21 +8,21 @@ require "fileutils"
|
||||
|
||||
class Foreman::Engine
|
||||
|
||||
attr_reader :pstypes
|
||||
attr_reader :psfile
|
||||
attr_reader :directory
|
||||
|
||||
extend Term::ANSIColor
|
||||
|
||||
COLORS = [ cyan, yellow, green, magenta, red ]
|
||||
|
||||
def initialize(pstypes)
|
||||
@pstypes = read_pstypes(pstypes)
|
||||
@directory = File.expand_path(File.dirname(pstypes))
|
||||
def initialize(psfile)
|
||||
@psfile = read_psfile(psfile)
|
||||
@directory = File.expand_path(File.dirname(psfile))
|
||||
end
|
||||
|
||||
def processes
|
||||
@processes ||= begin
|
||||
pstypes.split("\n").inject({}) do |hash, line|
|
||||
psfile.split("\n").inject({}) do |hash, line|
|
||||
next if line.strip == ""
|
||||
name, command = line.split(" ", 2)
|
||||
process = Foreman::Process.new(name, command)
|
||||
@@ -144,8 +144,8 @@ private ######################################################################
|
||||
$0 = title
|
||||
end
|
||||
|
||||
def read_pstypes(pstypes)
|
||||
File.read(pstypes)
|
||||
def read_psfile(psfile)
|
||||
File.read(psfile)
|
||||
end
|
||||
|
||||
def watch_for_termination
|
||||
|
||||
Reference in New Issue
Block a user