foreman 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/data/example/Procfile +2 -2
- data/data/example/Procfile.without_colon +2 -0
- data/lib/foreman/cli.rb +14 -1
- data/lib/foreman/engine.rb +14 -3
- data/lib/foreman/export/json.rb +13 -0
- data/lib/foreman/export.rb +2 -1
- data/lib/foreman.rb +1 -1
- data/man/foreman.1 +39 -6
- data/spec/foreman/cli_spec.rb +23 -0
- data/spec/foreman/engine_spec.rb +15 -1
- data/spec/spec_helper.rb +2 -2
- metadata +70 -40
data/data/example/Procfile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
ticker ./ticker $PORT
|
|
2
|
-
error
|
|
1
|
+
ticker: ./ticker $PORT
|
|
2
|
+
error : ./error
|
data/lib/foreman/cli.rb
CHANGED
|
@@ -36,8 +36,9 @@ class Foreman::CLI < Thor
|
|
|
36
36
|
check_procfile!
|
|
37
37
|
|
|
38
38
|
formatter = case format
|
|
39
|
-
when "
|
|
39
|
+
when "json" then Foreman::Export::JSON
|
|
40
40
|
when "inittab" then Foreman::Export::Inittab
|
|
41
|
+
when "upstart" then Foreman::Export::Upstart
|
|
41
42
|
else error "Unknown export format: #{format}."
|
|
42
43
|
end
|
|
43
44
|
|
|
@@ -47,6 +48,14 @@ class Foreman::CLI < Thor
|
|
|
47
48
|
error ex.message
|
|
48
49
|
end
|
|
49
50
|
|
|
51
|
+
desc "check", "Validate your application's Procfile"
|
|
52
|
+
|
|
53
|
+
def check
|
|
54
|
+
processes = engine.processes_in_order.map { |p| p.first }
|
|
55
|
+
error "no processes defined" unless processes.length > 0
|
|
56
|
+
display "valid procfile detected (#{processes.join(', ')})"
|
|
57
|
+
end
|
|
58
|
+
|
|
50
59
|
private ######################################################################
|
|
51
60
|
|
|
52
61
|
def check_procfile!
|
|
@@ -63,6 +72,10 @@ private ######################################################################
|
|
|
63
72
|
|
|
64
73
|
private ######################################################################
|
|
65
74
|
|
|
75
|
+
def display(message)
|
|
76
|
+
puts message
|
|
77
|
+
end
|
|
78
|
+
|
|
66
79
|
def error(message)
|
|
67
80
|
puts "ERROR: #{message}"
|
|
68
81
|
exit 1
|
data/lib/foreman/engine.rb
CHANGED
|
@@ -25,7 +25,11 @@ class Foreman::Engine
|
|
|
25
25
|
@order = []
|
|
26
26
|
procfile.split("\n").inject({}) do |hash, line|
|
|
27
27
|
next if line.strip == ""
|
|
28
|
-
name, command = line.split(
|
|
28
|
+
name, command = line.split(/ *: +/, 2)
|
|
29
|
+
unless command
|
|
30
|
+
warn_deprecated_procfile!
|
|
31
|
+
name, command = line.split(/ +/, 2)
|
|
32
|
+
end
|
|
29
33
|
process = Foreman::Process.new(name, command)
|
|
30
34
|
process.color = next_color
|
|
31
35
|
@order << process.name
|
|
@@ -95,12 +99,11 @@ private ######################################################################
|
|
|
95
99
|
running_processes[pid] = process
|
|
96
100
|
end
|
|
97
101
|
|
|
98
|
-
def run(process
|
|
102
|
+
def run(process)
|
|
99
103
|
proctitle "ruby: foreman #{process.name}"
|
|
100
104
|
|
|
101
105
|
begin
|
|
102
106
|
Dir.chdir directory do
|
|
103
|
-
FileUtils.mkdir_p "log"
|
|
104
107
|
command = process.command
|
|
105
108
|
|
|
106
109
|
PTY.spawn("#{process.command} 2>&1") do |stdin, stdout, pid|
|
|
@@ -179,4 +182,12 @@ private ######################################################################
|
|
|
179
182
|
@current_color >= COLORS.length ? "" : COLORS[@current_color]
|
|
180
183
|
end
|
|
181
184
|
|
|
185
|
+
def warn_deprecated_procfile!
|
|
186
|
+
return if @already_warned_deprecated
|
|
187
|
+
@already_warned_deprecated = true
|
|
188
|
+
puts "!!! This format of Procfile is deprecated, and will not work starting in v0.12"
|
|
189
|
+
puts "!!! Use a colon to separate the process name from the command"
|
|
190
|
+
puts "!!! e.g. web: thin start"
|
|
191
|
+
end
|
|
192
|
+
|
|
182
193
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "foreman/export/base"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
class Foreman::Export::JSON < Foreman::Export::Base
|
|
5
|
+
|
|
6
|
+
def export(fname=nil, options={})
|
|
7
|
+
processes = engine.processes.values.inject({}) do |hash, process|
|
|
8
|
+
hash.update(process.name => { "command" => process.command })
|
|
9
|
+
end
|
|
10
|
+
puts processes.to_json
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
data/lib/foreman/export.rb
CHANGED
data/lib/foreman.rb
CHANGED
data/man/foreman.1
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
|
3
3
|
.
|
|
4
|
-
.TH "FOREMAN" "1" "
|
|
4
|
+
.TH "FOREMAN" "1" "January 2011" "Foreman 0.10.1" "Foreman Manual"
|
|
5
5
|
.
|
|
6
6
|
.SH "NAME"
|
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
|
@@ -28,8 +28,12 @@ If a parameter is passed, foreman will run one instance of the specified applica
|
|
|
28
28
|
The following options control how the application is run:
|
|
29
29
|
.
|
|
30
30
|
.TP
|
|
31
|
-
\fB\-
|
|
32
|
-
|
|
31
|
+
\fB\-c\fR, \fB\-\-concurrency\fR
|
|
32
|
+
Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR
|
|
33
|
+
.
|
|
34
|
+
.TP
|
|
35
|
+
\fB\-p\fR, \fB\-\-port\fR
|
|
36
|
+
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
|
33
37
|
.
|
|
34
38
|
.SH "EXPORTING"
|
|
35
39
|
\fBforeman export\fR is used to export your application to another process management format\.
|
|
@@ -71,6 +75,9 @@ Specify an alternate location for the application\'s Procfile\. This file\'s con
|
|
|
71
75
|
foreman currently supports the following output formats:
|
|
72
76
|
.
|
|
73
77
|
.IP "\(bu" 4
|
|
78
|
+
json
|
|
79
|
+
.
|
|
80
|
+
.IP "\(bu" 4
|
|
74
81
|
inittab
|
|
75
82
|
.
|
|
76
83
|
.IP "\(bu" 4
|
|
@@ -78,6 +85,19 @@ upstart
|
|
|
78
85
|
.
|
|
79
86
|
.IP "" 0
|
|
80
87
|
.
|
|
88
|
+
.SH "JSON EXPORT"
|
|
89
|
+
Will export your processes as JSON:
|
|
90
|
+
.
|
|
91
|
+
.IP "" 4
|
|
92
|
+
.
|
|
93
|
+
.nf
|
|
94
|
+
|
|
95
|
+
{ "web": { "command": "bundle exec thin start" } }
|
|
96
|
+
.
|
|
97
|
+
.fi
|
|
98
|
+
.
|
|
99
|
+
.IP "" 0
|
|
100
|
+
.
|
|
81
101
|
.SH "INITTAB EXPORT"
|
|
82
102
|
Will export a chunk of inittab\-compatible configuration:
|
|
83
103
|
.
|
|
@@ -113,8 +133,21 @@ A Procfile should contain both a name for the process and the command used to ru
|
|
|
113
133
|
.
|
|
114
134
|
.nf
|
|
115
135
|
|
|
116
|
-
web
|
|
117
|
-
job
|
|
136
|
+
web: bundle exec thin start
|
|
137
|
+
job: bundle exec rake jobs:work
|
|
138
|
+
.
|
|
139
|
+
.fi
|
|
140
|
+
.
|
|
141
|
+
.IP "" 0
|
|
142
|
+
.
|
|
143
|
+
.P
|
|
144
|
+
You can validate your Procfile format using the \fBcheck\fR command
|
|
145
|
+
.
|
|
146
|
+
.IP "" 4
|
|
147
|
+
.
|
|
148
|
+
.nf
|
|
149
|
+
|
|
150
|
+
$ foreman check
|
|
118
151
|
.
|
|
119
152
|
.fi
|
|
120
153
|
.
|
|
@@ -153,7 +186,7 @@ Run one process type from the application defined in a specific Procfile:
|
|
|
153
186
|
.
|
|
154
187
|
.nf
|
|
155
188
|
|
|
156
|
-
$ foreman start alpha \-p ~/
|
|
189
|
+
$ foreman start alpha \-p ~/myapp/Procfile
|
|
157
190
|
.
|
|
158
191
|
.fi
|
|
159
192
|
.
|
data/spec/foreman/cli_spec.rb
CHANGED
|
@@ -58,4 +58,27 @@ describe "Foreman::CLI" do
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
describe "check" do
|
|
62
|
+
describe "with a valid Procfile" do
|
|
63
|
+
before { write_procfile }
|
|
64
|
+
|
|
65
|
+
it "displays the jobs" do
|
|
66
|
+
mock(subject).display("valid procfile detected (alpha, bravo)")
|
|
67
|
+
subject.check
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "with a blank Procfile" do
|
|
72
|
+
before do
|
|
73
|
+
FileUtils.touch("Procfile")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "displays an error" do
|
|
77
|
+
mock_error(subject, "no processes defined") do
|
|
78
|
+
subject.check
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
61
84
|
end
|
data/spec/foreman/engine_spec.rb
CHANGED
|
@@ -12,12 +12,26 @@ describe "Foreman::Engine" do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
describe "with a Procfile" do
|
|
15
|
+
before { write_procfile }
|
|
16
|
+
|
|
15
17
|
it "reads the processes" do
|
|
16
|
-
write_procfile
|
|
17
18
|
subject.processes["alpha"].command.should == "./alpha"
|
|
18
19
|
subject.processes["bravo"].command.should == "./bravo"
|
|
19
20
|
end
|
|
20
21
|
end
|
|
22
|
+
|
|
23
|
+
describe "with a deprecated Procfile" do
|
|
24
|
+
before do
|
|
25
|
+
File.open("Procfile", "w") do |file|
|
|
26
|
+
file.puts "name command"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should print a deprecation warning" do
|
|
31
|
+
mock(subject).warn_deprecated_procfile!
|
|
32
|
+
subject.processes.length.should == 1
|
|
33
|
+
end
|
|
34
|
+
end
|
|
21
35
|
end
|
|
22
36
|
|
|
23
37
|
describe "start" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 51
|
|
5
|
+
prerelease:
|
|
5
6
|
segments:
|
|
6
7
|
- 0
|
|
7
|
-
-
|
|
8
|
+
- 11
|
|
8
9
|
- 0
|
|
9
|
-
version: 0.
|
|
10
|
+
version: 0.11.0
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- |
|
|
@@ -16,138 +17,163 @@ autorequire:
|
|
|
16
17
|
bindir: bin
|
|
17
18
|
cert_chain: []
|
|
18
19
|
|
|
19
|
-
date:
|
|
20
|
+
date: 2011-01-27 00:00:00 -08:00
|
|
20
21
|
default_executable:
|
|
21
22
|
dependencies:
|
|
22
23
|
- !ruby/object:Gem::Dependency
|
|
23
|
-
|
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
|
25
25
|
none: false
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 3
|
|
29
30
|
segments:
|
|
30
31
|
- 0
|
|
31
32
|
version: "0"
|
|
32
|
-
|
|
33
|
+
requirement: *id001
|
|
33
34
|
prerelease: false
|
|
34
|
-
|
|
35
|
+
name: parka
|
|
36
|
+
type: :development
|
|
35
37
|
- !ruby/object:Gem::Dependency
|
|
36
|
-
|
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
|
38
39
|
none: false
|
|
39
40
|
requirements:
|
|
40
41
|
- - ">="
|
|
41
42
|
- !ruby/object:Gem::Version
|
|
43
|
+
hash: 3
|
|
42
44
|
segments:
|
|
43
45
|
- 0
|
|
44
46
|
version: "0"
|
|
45
|
-
|
|
47
|
+
requirement: *id002
|
|
46
48
|
prerelease: false
|
|
47
|
-
|
|
49
|
+
name: rake
|
|
50
|
+
type: :development
|
|
48
51
|
- !ruby/object:Gem::Dependency
|
|
49
|
-
|
|
50
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
|
51
53
|
none: false
|
|
52
54
|
requirements:
|
|
53
55
|
- - ">="
|
|
54
56
|
- !ruby/object:Gem::Version
|
|
57
|
+
hash: 3
|
|
55
58
|
segments:
|
|
56
59
|
- 0
|
|
57
60
|
version: "0"
|
|
58
|
-
|
|
61
|
+
requirement: *id003
|
|
59
62
|
prerelease: false
|
|
60
|
-
|
|
63
|
+
name: ronn
|
|
64
|
+
type: :development
|
|
61
65
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
|
|
63
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
|
66
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
|
64
67
|
none: false
|
|
65
68
|
requirements:
|
|
66
69
|
- - ~>
|
|
67
70
|
- !ruby/object:Gem::Version
|
|
71
|
+
hash: 21
|
|
68
72
|
segments:
|
|
69
73
|
- 0
|
|
70
74
|
- 2
|
|
71
75
|
- 1
|
|
72
76
|
version: 0.2.1
|
|
73
|
-
|
|
77
|
+
requirement: *id004
|
|
74
78
|
prerelease: false
|
|
75
|
-
|
|
79
|
+
name: fakefs
|
|
80
|
+
type: :development
|
|
76
81
|
- !ruby/object:Gem::Dependency
|
|
77
|
-
|
|
78
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
|
79
83
|
none: false
|
|
80
84
|
requirements:
|
|
81
85
|
- - ~>
|
|
82
86
|
- !ruby/object:Gem::Version
|
|
87
|
+
hash: 43
|
|
83
88
|
segments:
|
|
84
89
|
- 0
|
|
85
90
|
- 9
|
|
86
91
|
- 8
|
|
87
92
|
version: 0.9.8
|
|
88
|
-
|
|
93
|
+
requirement: *id005
|
|
89
94
|
prerelease: false
|
|
90
|
-
|
|
95
|
+
name: rcov
|
|
96
|
+
type: :development
|
|
91
97
|
- !ruby/object:Gem::Dependency
|
|
92
|
-
|
|
93
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
|
94
99
|
none: false
|
|
95
100
|
requirements:
|
|
96
101
|
- - ~>
|
|
97
102
|
- !ruby/object:Gem::Version
|
|
103
|
+
hash: 19
|
|
98
104
|
segments:
|
|
99
105
|
- 1
|
|
100
106
|
- 0
|
|
101
107
|
- 2
|
|
102
108
|
version: 1.0.2
|
|
103
|
-
|
|
109
|
+
requirement: *id006
|
|
104
110
|
prerelease: false
|
|
105
|
-
|
|
111
|
+
name: rr
|
|
112
|
+
type: :development
|
|
106
113
|
- !ruby/object:Gem::Dependency
|
|
107
|
-
|
|
108
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
|
114
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
|
109
115
|
none: false
|
|
110
116
|
requirements:
|
|
111
117
|
- - ~>
|
|
112
118
|
- !ruby/object:Gem::Version
|
|
119
|
+
hash: 15
|
|
113
120
|
segments:
|
|
114
121
|
- 2
|
|
115
122
|
- 0
|
|
116
123
|
- 0
|
|
117
124
|
version: 2.0.0
|
|
125
|
+
requirement: *id007
|
|
126
|
+
prerelease: false
|
|
127
|
+
name: rspec
|
|
118
128
|
type: :development
|
|
129
|
+
- !ruby/object:Gem::Dependency
|
|
130
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
|
131
|
+
none: false
|
|
132
|
+
requirements:
|
|
133
|
+
- - ~>
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
hash: 1
|
|
136
|
+
segments:
|
|
137
|
+
- 1
|
|
138
|
+
- 5
|
|
139
|
+
- 1
|
|
140
|
+
version: 1.5.1
|
|
141
|
+
requirement: *id008
|
|
119
142
|
prerelease: false
|
|
120
|
-
|
|
143
|
+
name: json
|
|
144
|
+
type: :runtime
|
|
121
145
|
- !ruby/object:Gem::Dependency
|
|
122
|
-
|
|
123
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
|
146
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
|
124
147
|
none: false
|
|
125
148
|
requirements:
|
|
126
149
|
- - ~>
|
|
127
150
|
- !ruby/object:Gem::Version
|
|
151
|
+
hash: 29
|
|
128
152
|
segments:
|
|
129
153
|
- 1
|
|
130
154
|
- 0
|
|
131
155
|
- 5
|
|
132
156
|
version: 1.0.5
|
|
133
|
-
|
|
157
|
+
requirement: *id009
|
|
134
158
|
prerelease: false
|
|
135
|
-
|
|
159
|
+
name: term-ansicolor
|
|
160
|
+
type: :runtime
|
|
136
161
|
- !ruby/object:Gem::Dependency
|
|
137
|
-
|
|
138
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
|
162
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
|
139
163
|
none: false
|
|
140
164
|
requirements:
|
|
141
165
|
- - ~>
|
|
142
166
|
- !ruby/object:Gem::Version
|
|
167
|
+
hash: 39
|
|
143
168
|
segments:
|
|
144
169
|
- 0
|
|
145
170
|
- 13
|
|
146
171
|
- 6
|
|
147
172
|
version: 0.13.6
|
|
148
|
-
|
|
173
|
+
requirement: *id010
|
|
149
174
|
prerelease: false
|
|
150
|
-
|
|
175
|
+
name: thor
|
|
176
|
+
type: :runtime
|
|
151
177
|
description: Process manager for applications with multiple components
|
|
152
178
|
email: |
|
|
153
179
|
<ddollar@gmail.com>
|
|
@@ -163,6 +189,7 @@ files:
|
|
|
163
189
|
- man/foreman.1
|
|
164
190
|
- README.markdown
|
|
165
191
|
- data/example/Procfile
|
|
192
|
+
- data/example/Procfile.without_colon
|
|
166
193
|
- data/example/error
|
|
167
194
|
- data/example/log/neverdie.log
|
|
168
195
|
- data/example/ticker
|
|
@@ -175,6 +202,7 @@ files:
|
|
|
175
202
|
- lib/foreman/export.rb
|
|
176
203
|
- lib/foreman/export/base.rb
|
|
177
204
|
- lib/foreman/export/inittab.rb
|
|
205
|
+
- lib/foreman/export/json.rb
|
|
178
206
|
- lib/foreman/export/upstart.rb
|
|
179
207
|
- lib/foreman/process.rb
|
|
180
208
|
- lib/foreman/utils.rb
|
|
@@ -199,6 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
199
227
|
requirements:
|
|
200
228
|
- - ">="
|
|
201
229
|
- !ruby/object:Gem::Version
|
|
230
|
+
hash: 3
|
|
202
231
|
segments:
|
|
203
232
|
- 0
|
|
204
233
|
version: "0"
|
|
@@ -207,13 +236,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
207
236
|
requirements:
|
|
208
237
|
- - ">="
|
|
209
238
|
- !ruby/object:Gem::Version
|
|
239
|
+
hash: 3
|
|
210
240
|
segments:
|
|
211
241
|
- 0
|
|
212
242
|
version: "0"
|
|
213
243
|
requirements: []
|
|
214
244
|
|
|
215
245
|
rubyforge_project: nowarning
|
|
216
|
-
rubygems_version: 1.
|
|
246
|
+
rubygems_version: 1.4.2
|
|
217
247
|
signing_key:
|
|
218
248
|
specification_version: 3
|
|
219
249
|
summary: Process manager for applications with multiple components
|