foreman 0.50.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +46 -0
- data/bin/foreman +7 -0
- data/bin/foreman-runner +32 -0
- data/bin/taskman +8 -0
- data/data/example/Procfile +4 -0
- data/data/example/Procfile.without_colon +2 -0
- data/data/example/error +7 -0
- data/data/example/log/neverdie.log +4 -0
- data/data/example/spawnee +14 -0
- data/data/example/spawner +7 -0
- data/data/example/ticker +14 -0
- data/data/example/utf8 +11 -0
- data/data/export/bluepill/master.pill.erb +28 -0
- data/data/export/launchd/launchd.plist.erb +22 -0
- data/data/export/runit/log/run.erb +7 -0
- data/data/export/runit/run.erb +3 -0
- data/data/export/supervisord/app.conf.erb +27 -0
- data/data/export/upstart/master.conf.erb +8 -0
- data/data/export/upstart/process.conf.erb +5 -0
- data/data/export/upstart/process_master.conf.erb +2 -0
- data/lib/foreman.rb +23 -0
- data/lib/foreman/cli.rb +140 -0
- data/lib/foreman/distribution.rb +9 -0
- data/lib/foreman/engine.rb +313 -0
- data/lib/foreman/engine/cli.rb +105 -0
- data/lib/foreman/env.rb +27 -0
- data/lib/foreman/export.rb +34 -0
- data/lib/foreman/export/base.rb +146 -0
- data/lib/foreman/export/bluepill.rb +12 -0
- data/lib/foreman/export/inittab.rb +33 -0
- data/lib/foreman/export/launchd.rb +15 -0
- data/lib/foreman/export/runit.rb +34 -0
- data/lib/foreman/export/supervisord.rb +16 -0
- data/lib/foreman/export/upstart.rb +25 -0
- data/lib/foreman/helpers.rb +45 -0
- data/lib/foreman/process.rb +102 -0
- data/lib/foreman/procfile.rb +92 -0
- data/lib/foreman/version.rb +5 -0
- data/man/foreman.1 +244 -0
- data/spec/foreman/cli_spec.rb +87 -0
- data/spec/foreman/engine_spec.rb +104 -0
- data/spec/foreman/export/base_spec.rb +19 -0
- data/spec/foreman/export/bluepill_spec.rb +37 -0
- data/spec/foreman/export/inittab_spec.rb +40 -0
- data/spec/foreman/export/launchd_spec.rb +21 -0
- data/spec/foreman/export/runit_spec.rb +36 -0
- data/spec/foreman/export/supervisord_spec.rb +36 -0
- data/spec/foreman/export/upstart_spec.rb +88 -0
- data/spec/foreman/export_spec.rb +24 -0
- data/spec/foreman/helpers_spec.rb +26 -0
- data/spec/foreman/process_spec.rb +48 -0
- data/spec/foreman/procfile_spec.rb +41 -0
- data/spec/foreman_spec.rb +16 -0
- data/spec/helper_spec.rb +18 -0
- data/spec/resources/Procfile +4 -0
- data/spec/resources/bin/echo +2 -0
- data/spec/resources/bin/env +2 -0
- data/spec/resources/bin/test +2 -0
- data/spec/resources/bin/utf8 +2 -0
- data/spec/resources/export/bluepill/app-concurrency.pill +49 -0
- data/spec/resources/export/bluepill/app.pill +46 -0
- data/spec/resources/export/inittab/inittab.concurrency +4 -0
- data/spec/resources/export/inittab/inittab.default +4 -0
- data/spec/resources/export/launchd/launchd-a.default +22 -0
- data/spec/resources/export/launchd/launchd-b.default +22 -0
- data/spec/resources/export/runit/app-alpha-1/log/run +7 -0
- data/spec/resources/export/runit/app-alpha-1/run +3 -0
- data/spec/resources/export/runit/app-alpha-2/log/run +7 -0
- data/spec/resources/export/runit/app-alpha-2/run +3 -0
- data/spec/resources/export/runit/app-bravo-1/log/run +7 -0
- data/spec/resources/export/runit/app-bravo-1/run +3 -0
- data/spec/resources/export/supervisord/app-alpha-1.conf +24 -0
- data/spec/resources/export/supervisord/app-alpha-2.conf +24 -0
- data/spec/resources/export/upstart/app-alpha-1.conf +5 -0
- data/spec/resources/export/upstart/app-alpha-2.conf +5 -0
- data/spec/resources/export/upstart/app-alpha.conf +2 -0
- data/spec/resources/export/upstart/app-bravo-1.conf +5 -0
- data/spec/resources/export/upstart/app-bravo.conf +2 -0
- data/spec/resources/export/upstart/app.conf +8 -0
- data/spec/spec_helper.rb +153 -0
- metadata +148 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
require "foreman"
|
2
|
+
|
3
|
+
# Reads and writes Procfiles
|
4
|
+
#
|
5
|
+
# A valid Procfile entry is captured by this regex:
|
6
|
+
#
|
7
|
+
# /^([A-Za-z0-9_]+):\s*(.+)$/
|
8
|
+
#
|
9
|
+
# All other lines are ignored.
|
10
|
+
#
|
11
|
+
class Foreman::Procfile
|
12
|
+
|
13
|
+
# Initialize a Procfile
|
14
|
+
#
|
15
|
+
# @param [String] filename (nil) An optional filename to read from
|
16
|
+
#
|
17
|
+
def initialize(filename=nil)
|
18
|
+
@entries = []
|
19
|
+
load(filename) if filename
|
20
|
+
end
|
21
|
+
|
22
|
+
# Yield each +Procfile+ entry in order
|
23
|
+
#
|
24
|
+
def entries(&blk)
|
25
|
+
@entries.each do |(name, command)|
|
26
|
+
yield name, command
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Retrieve a +Procfile+ command by name
|
31
|
+
#
|
32
|
+
# @param [String] name The name of the Procfile entry to retrieve
|
33
|
+
#
|
34
|
+
def [](name)
|
35
|
+
@entries.detect { |n,c| name == n }.last
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create a +Procfile+ entry
|
39
|
+
#
|
40
|
+
# @param [String] name The name of the +Procfile+ entry to create
|
41
|
+
# @param [String] command The command of the +Procfile+ entry to create
|
42
|
+
#
|
43
|
+
def []=(name, command)
|
44
|
+
delete name
|
45
|
+
@entries << [name, command]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Remove a +Procfile+ entry
|
49
|
+
#
|
50
|
+
# @param [String] name The name of the +Procfile+ entry to remove
|
51
|
+
#
|
52
|
+
def delete(name)
|
53
|
+
@entries.reject! { |n,c| name == n }
|
54
|
+
end
|
55
|
+
|
56
|
+
# Load a Procfile from a file
|
57
|
+
#
|
58
|
+
# @param [String] filename The filename of the +Procfile+ to load
|
59
|
+
#
|
60
|
+
def load(filename)
|
61
|
+
@entries.replace parse(filename)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Save a Procfile to a file
|
65
|
+
#
|
66
|
+
# @param [String] filename Save the +Procfile+ to this file
|
67
|
+
#
|
68
|
+
def save(filename)
|
69
|
+
File.open(filename, 'w') do |file|
|
70
|
+
file.puts self.to_s
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Get the +Procfile+ as a +String+
|
75
|
+
#
|
76
|
+
def to_s
|
77
|
+
@entries.map do |name, command|
|
78
|
+
[ name, command ].join(": ")
|
79
|
+
end.join("\n")
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def parse(filename)
|
85
|
+
File.read(filename).split("\n").map do |line|
|
86
|
+
if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
|
87
|
+
[$1, $2]
|
88
|
+
end
|
89
|
+
end.compact
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
data/man/foreman.1
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
+
.
|
4
|
+
.TH "FOREMAN" "1" "July 2012" "Foreman 0.50.0" "Foreman Manual"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBforeman\fR \- manage Procfile\-based applications
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBforeman start [process]\fR
|
11
|
+
.
|
12
|
+
.br
|
13
|
+
\fBforeman run <command>\fR
|
14
|
+
.
|
15
|
+
.br
|
16
|
+
\fBforeman export <format> [location]\fR
|
17
|
+
.
|
18
|
+
.SH "DESCRIPTION"
|
19
|
+
Foreman is a manager for Procfile\-based applications\. Its aim is to abstract away the details of the Procfile format, and allow you to either run your application directly or export it to some other process management format\.
|
20
|
+
.
|
21
|
+
.SH "RUNNING"
|
22
|
+
\fBforeman start\fR is used to run your application directly from the command line\.
|
23
|
+
.
|
24
|
+
.P
|
25
|
+
If no additional parameters are passed, foreman will run one instance of each type of process defined in your Procfile\.
|
26
|
+
.
|
27
|
+
.P
|
28
|
+
If a parameter is passed, foreman will run one instance of the specified application type\.
|
29
|
+
.
|
30
|
+
.P
|
31
|
+
The following options control how the application is run:
|
32
|
+
.
|
33
|
+
.TP
|
34
|
+
\fB\-c\fR, \fB\-\-concurrency\fR
|
35
|
+
Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR
|
36
|
+
.
|
37
|
+
.TP
|
38
|
+
\fB\-e\fR, \fB\-\-env\fR
|
39
|
+
Specify one or more \.env files to load
|
40
|
+
.
|
41
|
+
.TP
|
42
|
+
\fB\-f\fR, \fB\-\-procfile\fR
|
43
|
+
Specify an alternate Procfile to load, implies \fB\-d\fR at the Procfile root\.
|
44
|
+
.
|
45
|
+
.TP
|
46
|
+
\fB\-p\fR, \fB\-\-port\fR
|
47
|
+
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
48
|
+
.
|
49
|
+
.TP
|
50
|
+
\fB\-t\fR, \fB\-\-tmux\fR
|
51
|
+
Runs the processes in a tmux session\. Creates one window for each process and an extra window containing the output of each window (requires gawk)\.
|
52
|
+
.
|
53
|
+
.P
|
54
|
+
\fBforeman run\fR is used to run one\-off commands using the same environment as your defined processes\.
|
55
|
+
.
|
56
|
+
.SH "EXPORTING"
|
57
|
+
\fBforeman export\fR is used to export your application to another process management format\.
|
58
|
+
.
|
59
|
+
.P
|
60
|
+
An location to export can be passed as an argument\. This argument may be either required or optional depending on the export format\.
|
61
|
+
.
|
62
|
+
.P
|
63
|
+
The following options control how the application is run:
|
64
|
+
.
|
65
|
+
.TP
|
66
|
+
\fB\-a\fR, \fB\-\-app\fR
|
67
|
+
Use this name rather than the application\'s root directory name as the name of the application when exporting\.
|
68
|
+
.
|
69
|
+
.TP
|
70
|
+
\fB\-c\fR, \fB\-\-concurrency\fR
|
71
|
+
Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR
|
72
|
+
.
|
73
|
+
.TP
|
74
|
+
\fB\-l\fR, \fB\-\-log\fR
|
75
|
+
Specify the directory to place process logs in\.
|
76
|
+
.
|
77
|
+
.TP
|
78
|
+
\fB\-p\fR, \fB\-\-port\fR
|
79
|
+
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
80
|
+
.
|
81
|
+
.TP
|
82
|
+
\fB\-t\fR, \fB\-\-template\fR
|
83
|
+
Specify an alternate template to use for creating export files\. See \fIhttps://github\.com/ddollar/foreman/tree/master/data/export\fR for examples\.
|
84
|
+
.
|
85
|
+
.TP
|
86
|
+
\fB\-u\fR, \fB\-\-user\fR
|
87
|
+
Specify the user the application should be run as\. Defaults to the app name
|
88
|
+
.
|
89
|
+
.SH "GLOBAL OPTIONS"
|
90
|
+
These options control all modes of foreman\'s operation\.
|
91
|
+
.
|
92
|
+
.TP
|
93
|
+
\fB\-d\fR, \fB\-\-directory\fR
|
94
|
+
Specify an alternate application root\. This defaults to the directory containing the Procfile\.
|
95
|
+
.
|
96
|
+
.TP
|
97
|
+
\fB\-e\fR, \fB\-\-env\fR
|
98
|
+
Specify an alternate environment file\. You can specify more than one file by using: \fB\-\-env file1,file2\fR\.
|
99
|
+
.
|
100
|
+
.TP
|
101
|
+
\fB\-f\fR, \fB\-\-procfile\fR
|
102
|
+
Specify an alternate location for the application\'s Procfile\. This file\'s containing directory will be assumed to be the root directory of the application\.
|
103
|
+
.
|
104
|
+
.SH "EXPORT FORMATS"
|
105
|
+
foreman currently supports the following output formats:
|
106
|
+
.
|
107
|
+
.IP "\(bu" 4
|
108
|
+
bluepill
|
109
|
+
.
|
110
|
+
.IP "\(bu" 4
|
111
|
+
inittab
|
112
|
+
.
|
113
|
+
.IP "\(bu" 4
|
114
|
+
runit
|
115
|
+
.
|
116
|
+
.IP "\(bu" 4
|
117
|
+
upstart
|
118
|
+
.
|
119
|
+
.IP "" 0
|
120
|
+
.
|
121
|
+
.SH "INITTAB EXPORT"
|
122
|
+
Will export a chunk of inittab\-compatible configuration:
|
123
|
+
.
|
124
|
+
.IP "" 4
|
125
|
+
.
|
126
|
+
.nf
|
127
|
+
|
128
|
+
# \-\-\-\-\- foreman example processes \-\-\-\-\-
|
129
|
+
EX01:4:respawn:/bin/su \- example \-c \'PORT=5000 bundle exec thin start >> /var/log/web\-1\.log 2>&1\'
|
130
|
+
EX02:4:respawn:/bin/su \- example \-c \'PORT=5100 bundle exec rake jobs:work >> /var/log/job\-1\.log 2>&1\'
|
131
|
+
# \-\-\-\-\- end foreman example processes \-\-\-\-\-
|
132
|
+
.
|
133
|
+
.fi
|
134
|
+
.
|
135
|
+
.IP "" 0
|
136
|
+
.
|
137
|
+
.SH "UPSTART EXPORT"
|
138
|
+
Will create a series of upstart scripts in the location you specify\. Scripts will be structured to make the following commands valid:
|
139
|
+
.
|
140
|
+
.P
|
141
|
+
\fBstart appname\fR
|
142
|
+
.
|
143
|
+
.P
|
144
|
+
\fBstop appname\-processname\fR
|
145
|
+
.
|
146
|
+
.P
|
147
|
+
\fBrestart appname\-processname\-3\fR
|
148
|
+
.
|
149
|
+
.SH "PROCFILE"
|
150
|
+
A Procfile should contain both a name for the process and the command used to run it\.
|
151
|
+
.
|
152
|
+
.IP "" 4
|
153
|
+
.
|
154
|
+
.nf
|
155
|
+
|
156
|
+
web: bundle exec thin start
|
157
|
+
job: bundle exec rake jobs:work
|
158
|
+
.
|
159
|
+
.fi
|
160
|
+
.
|
161
|
+
.IP "" 0
|
162
|
+
.
|
163
|
+
.P
|
164
|
+
A process name may contain letters, numbers amd the underscore character\. You can validate your Procfile format using the \fBcheck\fR command:
|
165
|
+
.
|
166
|
+
.IP "" 4
|
167
|
+
.
|
168
|
+
.nf
|
169
|
+
|
170
|
+
$ foreman check
|
171
|
+
.
|
172
|
+
.fi
|
173
|
+
.
|
174
|
+
.IP "" 0
|
175
|
+
.
|
176
|
+
.SH "ENVIRONMENT"
|
177
|
+
If a \fB\.env\fR file exists in the current directory, the default environment will be read from it\. This file should contain key/value pairs, separated by \fB=\fR, with one key/value pair per line\.
|
178
|
+
.
|
179
|
+
.IP "" 4
|
180
|
+
.
|
181
|
+
.nf
|
182
|
+
|
183
|
+
FOO=bar
|
184
|
+
BAZ=qux
|
185
|
+
.
|
186
|
+
.fi
|
187
|
+
.
|
188
|
+
.IP "" 0
|
189
|
+
.
|
190
|
+
.SH "DEFAULT OPTIONS"
|
191
|
+
If a \fB\.foreman\fR 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:
|
192
|
+
.
|
193
|
+
.IP "" 4
|
194
|
+
.
|
195
|
+
.nf
|
196
|
+
|
197
|
+
concurrency: alpha=0,bravo=1
|
198
|
+
port: 15000
|
199
|
+
.
|
200
|
+
.fi
|
201
|
+
.
|
202
|
+
.IP "" 0
|
203
|
+
.
|
204
|
+
.SH "EXAMPLES"
|
205
|
+
Start one instance of each process type, interleave the output on stdout:
|
206
|
+
.
|
207
|
+
.IP "" 4
|
208
|
+
.
|
209
|
+
.nf
|
210
|
+
|
211
|
+
$ foreman start
|
212
|
+
.
|
213
|
+
.fi
|
214
|
+
.
|
215
|
+
.IP "" 0
|
216
|
+
.
|
217
|
+
.P
|
218
|
+
Export the application in upstart format:
|
219
|
+
.
|
220
|
+
.IP "" 4
|
221
|
+
.
|
222
|
+
.nf
|
223
|
+
|
224
|
+
$ foreman export upstart /etc/init
|
225
|
+
.
|
226
|
+
.fi
|
227
|
+
.
|
228
|
+
.IP "" 0
|
229
|
+
.
|
230
|
+
.P
|
231
|
+
Run one process type from the application defined in a specific Procfile:
|
232
|
+
.
|
233
|
+
.IP "" 4
|
234
|
+
.
|
235
|
+
.nf
|
236
|
+
|
237
|
+
$ foreman start alpha \-p ~/myapp/Procfile
|
238
|
+
.
|
239
|
+
.fi
|
240
|
+
.
|
241
|
+
.IP "" 0
|
242
|
+
.
|
243
|
+
.SH "COPYRIGHT"
|
244
|
+
Foreman is Copyright (C) 2010 David Dollar \fIhttp://daviddollar\.org\fR
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "foreman/cli"
|
3
|
+
|
4
|
+
describe "Foreman::CLI", :fakefs do
|
5
|
+
subject { Foreman::CLI.new }
|
6
|
+
|
7
|
+
describe ".foreman" do
|
8
|
+
before { File.open(".foreman", "w") { |f| f.puts "formation: alpha=2" } }
|
9
|
+
|
10
|
+
it "provides default options" do
|
11
|
+
subject.send(:options)["formation"].should == "alpha=2"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "is overridden by options at the cli" do
|
15
|
+
subject = Foreman::CLI.new([], :formation => "alpha=3")
|
16
|
+
subject.send(:options)["formation"].should == "alpha=3"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "start" do
|
21
|
+
describe "when a Procfile doesnt exist", :fakefs do
|
22
|
+
it "displays an error" do
|
23
|
+
mock_error(subject, "Procfile does not exist.") do
|
24
|
+
dont_allow.instance_of(Foreman::Engine).start
|
25
|
+
subject.start
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "with a valid Procfile" do
|
31
|
+
it "can run a single command" do
|
32
|
+
without_fakefs do
|
33
|
+
output = foreman("start env -f #{resource_path("Procfile")}")
|
34
|
+
output.should =~ /env.1/
|
35
|
+
output.should_not =~ /test.1/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can run all commands" do
|
40
|
+
without_fakefs do
|
41
|
+
output = foreman("start -f #{resource_path("Procfile")} -e #{resource_path(".env")}")
|
42
|
+
output.should =~ /echo.1 \| echoing/
|
43
|
+
output.should =~ /env.1 \| bar/
|
44
|
+
output.should =~ /test.1 \| testing/
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "check" do
|
51
|
+
it "with a valid Procfile displays the jobs" do
|
52
|
+
write_procfile
|
53
|
+
foreman("check").should == "valid procfile detected (alpha, bravo)\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "with a blank Procfile displays an error" do
|
57
|
+
FileUtils.touch "Procfile"
|
58
|
+
foreman("check").should == "ERROR: no processes defined\n"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "without a Procfile displays an error" do
|
62
|
+
FileUtils.rm_f "Procfile"
|
63
|
+
foreman("check").should == "ERROR: Procfile does not exist.\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "run" do
|
68
|
+
it "can run a command" do
|
69
|
+
forked_foreman("run echo 1").should == "1\n"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "includes the environment" do
|
73
|
+
forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "version" do
|
78
|
+
it "displays gem version" do
|
79
|
+
foreman("version").chomp.should == Foreman::VERSION
|
80
|
+
end
|
81
|
+
|
82
|
+
it "displays gem version on shortcut command" do
|
83
|
+
foreman("-v").chomp.should == Foreman::VERSION
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "foreman/engine"
|
3
|
+
|
4
|
+
class Foreman::Engine::Tester < Foreman::Engine
|
5
|
+
attr_reader :buffer
|
6
|
+
|
7
|
+
def startup
|
8
|
+
@buffer = ""
|
9
|
+
end
|
10
|
+
|
11
|
+
def output(name, data)
|
12
|
+
@buffer += "#{name}: #{data}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def shutdown
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "Foreman::Engine", :fakefs do
|
20
|
+
subject do
|
21
|
+
write_procfile "Procfile"
|
22
|
+
Foreman::Engine::Tester.new.load_procfile("Procfile")
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "initialize" do
|
26
|
+
describe "with a Procfile" do
|
27
|
+
before { write_procfile }
|
28
|
+
|
29
|
+
it "reads the processes" do
|
30
|
+
subject.process("alpha").command.should == "./alpha"
|
31
|
+
subject.process("bravo").command.should == "./bravo"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "start" do
|
37
|
+
it "forks the processes" do
|
38
|
+
mock(subject.process("alpha")).run(anything)
|
39
|
+
mock(subject.process("bravo")).run(anything)
|
40
|
+
mock(subject).watch_for_output
|
41
|
+
mock(subject).watch_for_termination
|
42
|
+
subject.start
|
43
|
+
end
|
44
|
+
|
45
|
+
it "handles concurrency" do
|
46
|
+
subject.options[:formation] = "alpha=2"
|
47
|
+
mock(subject.process("alpha")).run(anything).twice
|
48
|
+
mock(subject.process("bravo")).run(anything).never
|
49
|
+
mock(subject).watch_for_output
|
50
|
+
mock(subject).watch_for_termination
|
51
|
+
subject.start
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "directories" do
|
56
|
+
it "has the directory default relative to the Procfile" do
|
57
|
+
write_procfile "/some/app/Procfile"
|
58
|
+
engine = Foreman::Engine.new.load_procfile("/some/app/Procfile")
|
59
|
+
engine.root.should == "/some/app"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "environment" do
|
64
|
+
it "should read env files" do
|
65
|
+
File.open("/tmp/env", "w") { |f| f.puts("FOO=baz") }
|
66
|
+
subject.load_env("/tmp/env")
|
67
|
+
subject.env["FOO"].should == "baz"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should read more than one if specified" do
|
71
|
+
File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
|
72
|
+
File.open("/tmp/env2", "w") { |f| f.puts("BAZ=qux") }
|
73
|
+
subject.load_env "/tmp/env1"
|
74
|
+
subject.load_env "/tmp/env2"
|
75
|
+
subject.env["FOO"].should == "bar"
|
76
|
+
subject.env["BAZ"].should == "qux"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should handle quoted values" do
|
80
|
+
File.open("/tmp/env", "w") do |f|
|
81
|
+
f.puts 'FOO=bar'
|
82
|
+
f.puts 'BAZ="qux"'
|
83
|
+
f.puts "FRED='barney'"
|
84
|
+
f.puts 'OTHER="escaped\"quote"'
|
85
|
+
end
|
86
|
+
subject.load_env "/tmp/env"
|
87
|
+
subject.env["FOO"].should == "bar"
|
88
|
+
subject.env["BAZ"].should == "qux"
|
89
|
+
subject.env["FRED"].should == "barney"
|
90
|
+
subject.env["OTHER"].should == 'escaped"quote'
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should fail if specified and doesnt exist" do
|
94
|
+
lambda { subject.load_env "/tmp/env" }.should raise_error(Errno::ENOENT)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should set port from .env if specified" do
|
98
|
+
File.open("/tmp/env", "w") { |f| f.puts("PORT=9000") }
|
99
|
+
subject.load_env "/tmp/env"
|
100
|
+
subject.send(:base_port).should == 9000
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|