change back to Procfile
This commit is contained in:
@@ -5,7 +5,7 @@ require "thor"
|
||||
|
||||
class Foreman::CLI < Thor
|
||||
|
||||
class_option :psfile, :type => :string, :aliases => "-f", :desc => "Default: Psfile"
|
||||
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile"
|
||||
|
||||
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_psfile!
|
||||
check_procfile!
|
||||
|
||||
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_psfile!
|
||||
check_procfile!
|
||||
|
||||
formatter = case format
|
||||
when "upstart" then Foreman::Export::Upstart
|
||||
@@ -49,16 +49,16 @@ class Foreman::CLI < Thor
|
||||
|
||||
private ######################################################################
|
||||
|
||||
def check_psfile!
|
||||
error("#{psfile} does not exist.") unless File.exist?(psfile)
|
||||
def check_procfile!
|
||||
error("#{procfile} does not exist.") unless File.exist?(procfile)
|
||||
end
|
||||
|
||||
def engine
|
||||
@engine ||= Foreman::Engine.new(psfile)
|
||||
@engine ||= Foreman::Engine.new(procfile)
|
||||
end
|
||||
|
||||
def psfile
|
||||
options[:psfile] || "Psfile"
|
||||
def procfile
|
||||
options[:procfile] || "Procfile"
|
||||
end
|
||||
|
||||
private ######################################################################
|
||||
@@ -68,8 +68,8 @@ private ######################################################################
|
||||
exit 1
|
||||
end
|
||||
|
||||
def psfile_exists?(psfile)
|
||||
File.exist?(psfile)
|
||||
def procfile_exists?(procfile)
|
||||
File.exist?(procfile)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,21 +8,21 @@ require "fileutils"
|
||||
|
||||
class Foreman::Engine
|
||||
|
||||
attr_reader :psfile
|
||||
attr_reader :procfile
|
||||
attr_reader :directory
|
||||
|
||||
extend Term::ANSIColor
|
||||
|
||||
COLORS = [ cyan, yellow, green, magenta, red ]
|
||||
|
||||
def initialize(psfile)
|
||||
@psfile = read_psfile(psfile)
|
||||
@directory = File.expand_path(File.dirname(psfile))
|
||||
def initialize(procfile)
|
||||
@procfile = read_procfile(procfile)
|
||||
@directory = File.expand_path(File.dirname(procfile))
|
||||
end
|
||||
|
||||
def processes
|
||||
@processes ||= begin
|
||||
psfile.split("\n").inject({}) do |hash, line|
|
||||
procfile.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_psfile(psfile)
|
||||
File.read(psfile)
|
||||
def read_procfile(procfile)
|
||||
File.read(procfile)
|
||||
end
|
||||
|
||||
def watch_for_termination
|
||||
|
||||
@@ -5,17 +5,17 @@ describe "Foreman::CLI" do
|
||||
subject { Foreman::CLI.new }
|
||||
|
||||
describe "start" do
|
||||
describe "with a non-existent Psfile" do
|
||||
describe "with a non-existent Procfile" do
|
||||
it "prints an error" do
|
||||
mock_error(subject, "Psfile does not exist.") do
|
||||
mock_error(subject, "Procfile does not exist.") do
|
||||
dont_allow.instance_of(Foreman::Engine).start
|
||||
subject.start
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a Psfile" do
|
||||
before(:each) { write_psfile }
|
||||
describe "with a Procfile" do
|
||||
before(:each) { write_procfile }
|
||||
|
||||
it "runs successfully" do
|
||||
dont_allow(subject).error
|
||||
@@ -26,17 +26,17 @@ describe "Foreman::CLI" do
|
||||
end
|
||||
|
||||
describe "export" do
|
||||
describe "with a non-existent Psfile" do
|
||||
describe "with a non-existent Procfile" do
|
||||
it "prints an error" do
|
||||
mock_error(subject, "Psfile does not exist.") do
|
||||
mock_error(subject, "Procfile does not exist.") do
|
||||
dont_allow.instance_of(Foreman::Engine).export
|
||||
subject.export("testapp")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a Psfile" do
|
||||
before(:each) { write_psfile }
|
||||
describe "with a Procfile" do
|
||||
before(:each) { write_procfile }
|
||||
|
||||
describe "with an invalid formatter" do
|
||||
it "prints an error" do
|
||||
|
||||
@@ -2,18 +2,18 @@ require "spec_helper"
|
||||
require "foreman/engine"
|
||||
|
||||
describe "Foreman::Engine" do
|
||||
subject { Foreman::Engine.new("Psfile") }
|
||||
subject { Foreman::Engine.new("Procfile") }
|
||||
|
||||
describe "initialize" do
|
||||
describe "without an existing Psfile" do
|
||||
describe "without an existing Procfile" do
|
||||
it "raises an error" do
|
||||
lambda { subject }.should raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a Psfile" do
|
||||
describe "with a Procfile" do
|
||||
it "reads the processes" do
|
||||
write_psfile
|
||||
write_procfile
|
||||
subject.processes["alpha"].command.should == "./alpha"
|
||||
subject.processes["bravo"].command.should == "./bravo"
|
||||
end
|
||||
@@ -22,7 +22,7 @@ describe "Foreman::Engine" do
|
||||
|
||||
describe "start" do
|
||||
it "forks the processes" do
|
||||
write_psfile
|
||||
write_procfile
|
||||
mock(subject).fork(subject.processes["alpha"], {})
|
||||
mock(subject).fork(subject.processes["bravo"], {})
|
||||
mock(subject).watch_for_termination
|
||||
@@ -30,7 +30,7 @@ describe "Foreman::Engine" do
|
||||
end
|
||||
|
||||
it "handles concurrency" do
|
||||
write_psfile
|
||||
write_procfile
|
||||
mock(subject).fork_individual(subject.processes["alpha"], 1, 5000)
|
||||
mock(subject).fork_individual(subject.processes["alpha"], 2, 5001)
|
||||
mock(subject).fork_individual(subject.processes["bravo"], 1, 5100)
|
||||
@@ -41,7 +41,7 @@ describe "Foreman::Engine" do
|
||||
|
||||
describe "execute" do
|
||||
it "runs the processes" do
|
||||
write_psfile
|
||||
write_procfile
|
||||
mock(subject).fork(subject.processes["alpha"], {})
|
||||
mock(subject).watch_for_termination
|
||||
subject.execute("alpha")
|
||||
|
||||
@@ -24,8 +24,8 @@ def write_foreman_config(app)
|
||||
end
|
||||
end
|
||||
|
||||
def write_psfile(psfile="Psfile")
|
||||
File.open(psfile, "w") do |file|
|
||||
def write_procfile(procfile="Procfile")
|
||||
File.open(procfile, "w") do |file|
|
||||
file.puts "alpha ./alpha"
|
||||
file.puts "bravo ./bravo"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user