change back to Procfile

This commit is contained in:
David Dollar committed 2010-11-03 14:05:06 -07:00
1 parent eca48170a5
commit 9e42dfb253
6 files changed
+34 -34

No files matched your search

File renamed without changes.
+10 -10
View File
@@ -5,7 +5,7 @@ require "thor"
class Foreman::CLI < 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" desc "start [PROCESS]", "Start the application, or a specific process"
@@ -14,7 +14,7 @@ class Foreman::CLI < Thor
:banner => '"alpha=5,bar=3"' :banner => '"alpha=5,bar=3"'
def start(process=nil) def start(process=nil)
check_psfile! check_procfile!
if process if process
engine.execute(process, options) engine.execute(process, options)
@@ -33,7 +33,7 @@ class Foreman::CLI < Thor
:banner => '"alpha=5,bar=3"' :banner => '"alpha=5,bar=3"'
def export(format, location=nil) def export(format, location=nil)
check_psfile! check_procfile!
formatter = case format formatter = case format
when "upstart" then Foreman::Export::Upstart when "upstart" then Foreman::Export::Upstart
@@ -49,16 +49,16 @@ class Foreman::CLI < Thor
private ###################################################################### private ######################################################################
def check_psfile! def check_procfile!
error("#{psfile} does not exist.") unless File.exist?(psfile) error("#{procfile} does not exist.") unless File.exist?(procfile)
end end
def engine def engine
@engine ||= Foreman::Engine.new(psfile) @engine ||= Foreman::Engine.new(procfile)
end end
def psfile def procfile
options[:psfile] || "Psfile" options[:procfile] || "Procfile"
end end
private ###################################################################### private ######################################################################
@@ -68,8 +68,8 @@ private ######################################################################
exit 1 exit 1
end end
def psfile_exists?(psfile) def procfile_exists?(procfile)
File.exist?(psfile) File.exist?(procfile)
end end
end end
+7 -7
View File
@@ -8,21 +8,21 @@ require "fileutils"
class Foreman::Engine class Foreman::Engine
attr_reader :psfile attr_reader :procfile
attr_reader :directory attr_reader :directory
extend Term::ANSIColor extend Term::ANSIColor
COLORS = [ cyan, yellow, green, magenta, red ] COLORS = [ cyan, yellow, green, magenta, red ]
def initialize(psfile) def initialize(procfile)
@psfile = read_psfile(psfile) @procfile = read_procfile(procfile)
@directory = File.expand_path(File.dirname(psfile)) @directory = File.expand_path(File.dirname(procfile))
end end
def processes def processes
@processes ||= begin @processes ||= begin
psfile.split("\n").inject({}) do |hash, line| procfile.split("\n").inject({}) do |hash, line|
next if line.strip == "" next if line.strip == ""
name, command = line.split(" ", 2) name, command = line.split(" ", 2)
process = Foreman::Process.new(name, command) process = Foreman::Process.new(name, command)
@@ -144,8 +144,8 @@ private ######################################################################
$0 = title $0 = title
end end
def read_psfile(psfile) def read_procfile(procfile)
File.read(psfile) File.read(procfile)
end end
def watch_for_termination def watch_for_termination
+8 -8
View File
@@ -5,17 +5,17 @@ describe "Foreman::CLI" do
subject { Foreman::CLI.new } subject { Foreman::CLI.new }
describe "start" do describe "start" do
describe "with a non-existent Psfile" do describe "with a non-existent Procfile" do
it "prints an error" 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 dont_allow.instance_of(Foreman::Engine).start
subject.start subject.start
end end
end end
end end
describe "with a Psfile" do describe "with a Procfile" do
before(:each) { write_psfile } before(:each) { write_procfile }
it "runs successfully" do it "runs successfully" do
dont_allow(subject).error dont_allow(subject).error
@@ -26,17 +26,17 @@ describe "Foreman::CLI" do
end end
describe "export" do describe "export" do
describe "with a non-existent Psfile" do describe "with a non-existent Procfile" do
it "prints an error" 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 dont_allow.instance_of(Foreman::Engine).export
subject.export("testapp") subject.export("testapp")
end end
end end
end end
describe "with a Psfile" do describe "with a Procfile" do
before(:each) { write_psfile } before(:each) { write_procfile }
describe "with an invalid formatter" do describe "with an invalid formatter" do
it "prints an error" do it "prints an error" do
+7 -7
View File
@@ -2,18 +2,18 @@ require "spec_helper"
require "foreman/engine" require "foreman/engine"
describe "Foreman::Engine" do describe "Foreman::Engine" do
subject { Foreman::Engine.new("Psfile") } subject { Foreman::Engine.new("Procfile") }
describe "initialize" do describe "initialize" do
describe "without an existing Psfile" do describe "without an existing Procfile" do
it "raises an error" do it "raises an error" do
lambda { subject }.should raise_error lambda { subject }.should raise_error
end end
end end
describe "with a Psfile" do describe "with a Procfile" do
it "reads the processes" do it "reads the processes" do
write_psfile write_procfile
subject.processes["alpha"].command.should == "./alpha" subject.processes["alpha"].command.should == "./alpha"
subject.processes["bravo"].command.should == "./bravo" subject.processes["bravo"].command.should == "./bravo"
end end
@@ -22,7 +22,7 @@ describe "Foreman::Engine" do
describe "start" do describe "start" do
it "forks the processes" do it "forks the processes" do
write_psfile write_procfile
mock(subject).fork(subject.processes["alpha"], {}) mock(subject).fork(subject.processes["alpha"], {})
mock(subject).fork(subject.processes["bravo"], {}) mock(subject).fork(subject.processes["bravo"], {})
mock(subject).watch_for_termination mock(subject).watch_for_termination
@@ -30,7 +30,7 @@ describe "Foreman::Engine" do
end end
it "handles concurrency" do it "handles concurrency" do
write_psfile write_procfile
mock(subject).fork_individual(subject.processes["alpha"], 1, 5000) mock(subject).fork_individual(subject.processes["alpha"], 1, 5000)
mock(subject).fork_individual(subject.processes["alpha"], 2, 5001) mock(subject).fork_individual(subject.processes["alpha"], 2, 5001)
mock(subject).fork_individual(subject.processes["bravo"], 1, 5100) mock(subject).fork_individual(subject.processes["bravo"], 1, 5100)
@@ -41,7 +41,7 @@ describe "Foreman::Engine" do
describe "execute" do describe "execute" do
it "runs the processes" do it "runs the processes" do
write_psfile write_procfile
mock(subject).fork(subject.processes["alpha"], {}) mock(subject).fork(subject.processes["alpha"], {})
mock(subject).watch_for_termination mock(subject).watch_for_termination
subject.execute("alpha") subject.execute("alpha")
+2 -2
View File
@@ -24,8 +24,8 @@ def write_foreman_config(app)
end end
end end
def write_psfile(psfile="Psfile") def write_procfile(procfile="Procfile")
File.open(psfile, "w") do |file| File.open(procfile, "w") do |file|
file.puts "alpha ./alpha" file.puts "alpha ./alpha"
file.puts "bravo ./bravo" file.puts "bravo ./bravo"
end end