Compare commits

...

7 Commits

Author SHA1 Message Date
David Dollar
a3e758ab6c 0.23.1 2011-10-04 09:56:39 -04:00
David Dollar
5dc232a7b1 Merge pull request #79 from fdr/runner-dead-code
Eliminate dead code
2011-10-04 05:14:50 -07:00
Dan Farina
4191cb7b9c Eliminate dead code
An oversight; this code should probably have been pruned in
20e598abcc.

Signed-off-by: Dan Farina <drfarina@acm.org>
2011-10-04 00:19:04 -07:00
David Dollar
90d4dffb82 tweak docs 2011-09-16 18:46:10 -04:00
David Dollar
823f307abc doc updates 2011-09-16 18:42:57 -04:00
David Dollar
ed44a11e21 0.23.0 2011-09-16 18:25:02 -04:00
David Dollar
5719f4fc72 allow multiple environment files to be specified 2011-09-16 18:24:38 -04:00
6 changed files with 33 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.22.0)
foreman (0.23.1)
term-ansicolor (~> 1.0.5)
thor (>= 0.13.6)

View File

@@ -22,7 +22,7 @@ class Foreman::Engine
@procfile = read_procfile(procfile)
@directory = File.expand_path(File.dirname(procfile))
@options = options
@environment = read_environment(options[:env])
@environment = read_environment_files(options[:env])
end
def processes
@@ -202,24 +202,27 @@ private ######################################################################
puts "!!! e.g. web: thin start"
end
def read_environment(filename)
error "No such file: #{filename}" if filename && !File.exists?(filename)
filename ||= ".env"
def read_environment_files(filenames)
environment = {}
if File.exists?(filename)
File.read(filename).split("\n").each do |line|
if line =~ /\A([A-Za-z_]+)=(.*)\z/
environment[$1] = $2
end
end
(filenames || "").split(",").map(&:strip).each do |filename|
error "No such file: #{filename}" unless File.exists?(filename)
environment.merge!(read_environment(filename))
end
environment.merge!(read_environment(".env")) unless filenames
environment
end
def runner
File.expand_path("../../../bin/foreman-runner", __FILE__)
def read_environment(filename)
return {} unless File.exists?(filename)
File.read(filename).split("\n").inject({}) do |hash, line|
if line =~ /\A([A-Za-z_]+)=(.*)\z/
hash[$1] = $2
end
hash
end
end
def terminate_gracefully

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.22.0"
VERSION = "0.23.1"
end

View File

@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "FOREMAN" "1" "September 2011" "Foreman 0.21.0" "Foreman Manual"
.TH "FOREMAN" "1" "September 2011" "Foreman 0.23.0" "Foreman Manual"
.
.SH "NAME"
\fBforeman\fR \- manage Procfile\-based applications
@@ -69,7 +69,7 @@ These options control all modes of foreman\'s operation\.
.
.TP
\fB\-e\fR, \fB\-\-env\fR
Specify an alternate environment file\.
Specify an alternate environment file\. You can specify more than one file by using: \fB\-\-env file1,file2\fR\.
.
.TP
\fB\-f\fR, \fB\-\-procfile\fR
@@ -165,7 +165,7 @@ If a \fB\.foreman\fR file exists in the current directory, default options will
.
.nf
concurrency: alpha=0
concurrency: alpha=0,bravo=1
port: 15000
.
.fi

View File

@@ -67,7 +67,8 @@ The following options control how the application is run:
These options control all modes of foreman's operation.
* `-e`, `--env`:
Specify an alternate environment file.
Specify an alternate environment file. You can specify more than one
file by using: `--env file1,file2`.
* `-f`, `--procfile`:
Specify an alternate location for the application's Procfile. This file's
@@ -131,7 +132,7 @@ If a `.foreman` file exists in the current directory, default options will
be read from it. This file should be in YAML format with the long option
name as keys. Example:
concurrency: alpha=0
concurrency: alpha=0,bravo=1
port: 15000
## EXAMPLES

View File

@@ -79,6 +79,16 @@ describe "Foreman::Engine" do
engine.execute("alpha")
end
it "should read more than one if specified" do
File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
File.open("/tmp/env2", "w") { |f| f.puts("BAZ=qux") }
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env1,/tmp/env2")
stub(engine).info
mock(engine).watch_for_termination
engine.environment.should == { "FOO"=>"bar", "BAZ"=>"qux" }
engine.execute("alpha")
end
it "should fail if specified and doesnt exist" do
mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")