Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3e758ab6c | ||
|
|
5dc232a7b1 | ||
|
|
4191cb7b9c | ||
|
|
90d4dffb82 | ||
|
|
823f307abc | ||
|
|
ed44a11e21 | ||
|
|
5719f4fc72 |
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.22.0)
|
foreman (0.23.1)
|
||||||
term-ansicolor (~> 1.0.5)
|
term-ansicolor (~> 1.0.5)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
|
|||||||
+15
-12
@@ -22,7 +22,7 @@ class Foreman::Engine
|
|||||||
@procfile = read_procfile(procfile)
|
@procfile = read_procfile(procfile)
|
||||||
@directory = File.expand_path(File.dirname(procfile))
|
@directory = File.expand_path(File.dirname(procfile))
|
||||||
@options = options
|
@options = options
|
||||||
@environment = read_environment(options[:env])
|
@environment = read_environment_files(options[:env])
|
||||||
end
|
end
|
||||||
|
|
||||||
def processes
|
def processes
|
||||||
@@ -202,24 +202,27 @@ private ######################################################################
|
|||||||
puts "!!! e.g. web: thin start"
|
puts "!!! e.g. web: thin start"
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_environment(filename)
|
def read_environment_files(filenames)
|
||||||
error "No such file: #{filename}" if filename && !File.exists?(filename)
|
|
||||||
filename ||= ".env"
|
|
||||||
environment = {}
|
environment = {}
|
||||||
|
|
||||||
if File.exists?(filename)
|
(filenames || "").split(",").map(&:strip).each do |filename|
|
||||||
File.read(filename).split("\n").each do |line|
|
error "No such file: #{filename}" unless File.exists?(filename)
|
||||||
if line =~ /\A([A-Za-z_]+)=(.*)\z/
|
environment.merge!(read_environment(filename))
|
||||||
environment[$1] = $2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
environment.merge!(read_environment(".env")) unless filenames
|
||||||
environment
|
environment
|
||||||
end
|
end
|
||||||
|
|
||||||
def runner
|
def read_environment(filename)
|
||||||
File.expand_path("../../../bin/foreman-runner", __FILE__)
|
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
|
end
|
||||||
|
|
||||||
def terminate_gracefully
|
def terminate_gracefully
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Foreman
|
module Foreman
|
||||||
|
|
||||||
VERSION = "0.22.0"
|
VERSION = "0.23.1"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.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"
|
.SH "NAME"
|
||||||
\fBforeman\fR \- manage Procfile\-based applications
|
\fBforeman\fR \- manage Procfile\-based applications
|
||||||
@@ -69,7 +69,7 @@ These options control all modes of foreman\'s operation\.
|
|||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-e\fR, \fB\-\-env\fR
|
\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
|
.TP
|
||||||
\fB\-f\fR, \fB\-\-procfile\fR
|
\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
|
.nf
|
||||||
|
|
||||||
concurrency: alpha=0
|
concurrency: alpha=0,bravo=1
|
||||||
port: 15000
|
port: 15000
|
||||||
.
|
.
|
||||||
.fi
|
.fi
|
||||||
|
|||||||
+3
-2
@@ -67,7 +67,8 @@ The following options control how the application is run:
|
|||||||
These options control all modes of foreman's operation.
|
These options control all modes of foreman's operation.
|
||||||
|
|
||||||
* `-e`, `--env`:
|
* `-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`:
|
* `-f`, `--procfile`:
|
||||||
Specify an alternate location for the application's Procfile. This file's
|
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
|
be read from it. This file should be in YAML format with the long option
|
||||||
name as keys. Example:
|
name as keys. Example:
|
||||||
|
|
||||||
concurrency: alpha=0
|
concurrency: alpha=0,bravo=1
|
||||||
port: 15000
|
port: 15000
|
||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|||||||
@@ -79,6 +79,16 @@ describe "Foreman::Engine" do
|
|||||||
engine.execute("alpha")
|
engine.execute("alpha")
|
||||||
end
|
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
|
it "should fail if specified and doesnt exist" do
|
||||||
mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
|
mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
|
||||||
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
||||||
|
|||||||
Reference in New Issue
Block a user