foreman 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- ticker ./ticker $PORT
2
- error ./error
1
+ ticker: ./ticker $PORT
2
+ error : ./error
@@ -0,0 +1,2 @@
1
+ ticker ./ticker $PORT
2
+ error ./error
@@ -1,6 +1,6 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.10.1"
3
+ VERSION = "0.11.0"
4
4
 
5
5
  class AppDoesNotExist < Exception; end
6
6
 
@@ -36,8 +36,9 @@ class Foreman::CLI < Thor
36
36
  check_procfile!
37
37
 
38
38
  formatter = case format
39
- when "upstart" then Foreman::Export::Upstart
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
@@ -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(/:? +/, 2)
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
@@ -178,4 +182,12 @@ private ######################################################################
178
182
  @current_color >= COLORS.length ? "" : COLORS[@current_color]
179
183
  end
180
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
+
181
193
  end
@@ -4,5 +4,6 @@ module Foreman::Export
4
4
  class Exception < ::Exception; end
5
5
  end
6
6
 
7
- require "foreman/export/upstart"
7
+ require "foreman/export/json"
8
8
  require "foreman/export/inittab"
9
+ require "foreman/export/upstart"
@@ -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
@@ -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" "December 2010" "Foreman 0.10.0" "Foreman Manual"
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
@@ -75,6 +75,9 @@ Specify an alternate location for the application\'s Procfile\. This file\'s con
75
75
  foreman currently supports the following output formats:
76
76
  .
77
77
  .IP "\(bu" 4
78
+ json
79
+ .
80
+ .IP "\(bu" 4
78
81
  inittab
79
82
  .
80
83
  .IP "\(bu" 4
@@ -82,6 +85,19 @@ upstart
82
85
  .
83
86
  .IP "" 0
84
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
+ .
85
101
  .SH "INITTAB EXPORT"
86
102
  Will export a chunk of inittab\-compatible configuration:
87
103
  .
@@ -117,8 +133,21 @@ A Procfile should contain both a name for the process and the command used to ru
117
133
  .
118
134
  .nf
119
135
 
120
- web: bundle exec thin start
121
- job: bundle exec rake jobs:work
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
122
151
  .
123
152
  .fi
124
153
  .
@@ -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
@@ -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
@@ -26,7 +26,7 @@ end
26
26
 
27
27
  def write_procfile(procfile="Procfile")
28
28
  File.open(procfile, "w") do |file|
29
- file.puts "alpha ./alpha"
29
+ file.puts "alpha: ./alpha"
30
30
  file.puts "bravo: ./bravo"
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
5
- prerelease: false
4
+ hash: 51
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 10
9
- - 1
10
- version: 0.10.1
8
+ - 11
9
+ - 0
10
+ version: 0.11.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - |
@@ -17,11 +17,11 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-12-22 00:00:00 -05:00
20
+ date: 2011-01-27 00:00:00 -08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
@@ -30,12 +30,12 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  version: "0"
33
- type: :development
34
- name: parka
33
+ requirement: *id001
35
34
  prerelease: false
36
- version_requirements: *id001
35
+ name: parka
36
+ type: :development
37
37
  - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ">="
@@ -44,12 +44,12 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  version: "0"
47
- type: :development
48
- name: rake
47
+ requirement: *id002
49
48
  prerelease: false
50
- version_requirements: *id002
49
+ name: rake
50
+ type: :development
51
51
  - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ">="
@@ -58,12 +58,12 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  version: "0"
61
- type: :development
62
- name: ronn
61
+ requirement: *id003
63
62
  prerelease: false
64
- version_requirements: *id003
63
+ name: ronn
64
+ type: :development
65
65
  - !ruby/object:Gem::Dependency
66
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ~>
@@ -74,12 +74,12 @@ dependencies:
74
74
  - 2
75
75
  - 1
76
76
  version: 0.2.1
77
- type: :development
78
- name: fakefs
77
+ requirement: *id004
79
78
  prerelease: false
80
- version_requirements: *id004
79
+ name: fakefs
80
+ type: :development
81
81
  - !ruby/object:Gem::Dependency
82
- requirement: &id005 !ruby/object:Gem::Requirement
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -90,12 +90,12 @@ dependencies:
90
90
  - 9
91
91
  - 8
92
92
  version: 0.9.8
93
- type: :development
94
- name: rcov
93
+ requirement: *id005
95
94
  prerelease: false
96
- version_requirements: *id005
95
+ name: rcov
96
+ type: :development
97
97
  - !ruby/object:Gem::Dependency
98
- requirement: &id006 !ruby/object:Gem::Requirement
98
+ version_requirements: &id006 !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements:
101
101
  - - ~>
@@ -106,12 +106,12 @@ dependencies:
106
106
  - 0
107
107
  - 2
108
108
  version: 1.0.2
109
- type: :development
110
- name: rr
109
+ requirement: *id006
111
110
  prerelease: false
112
- version_requirements: *id006
111
+ name: rr
112
+ type: :development
113
113
  - !ruby/object:Gem::Dependency
114
- requirement: &id007 !ruby/object:Gem::Requirement
114
+ version_requirements: &id007 !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
117
117
  - - ~>
@@ -122,12 +122,28 @@ dependencies:
122
122
  - 0
123
123
  - 0
124
124
  version: 2.0.0
125
- type: :development
125
+ requirement: *id007
126
+ prerelease: false
126
127
  name: rspec
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
127
142
  prerelease: false
128
- version_requirements: *id007
143
+ name: json
144
+ type: :runtime
129
145
  - !ruby/object:Gem::Dependency
130
- requirement: &id008 !ruby/object:Gem::Requirement
146
+ version_requirements: &id009 !ruby/object:Gem::Requirement
131
147
  none: false
132
148
  requirements:
133
149
  - - ~>
@@ -138,12 +154,12 @@ dependencies:
138
154
  - 0
139
155
  - 5
140
156
  version: 1.0.5
141
- type: :runtime
142
- name: term-ansicolor
157
+ requirement: *id009
143
158
  prerelease: false
144
- version_requirements: *id008
159
+ name: term-ansicolor
160
+ type: :runtime
145
161
  - !ruby/object:Gem::Dependency
146
- requirement: &id009 !ruby/object:Gem::Requirement
162
+ version_requirements: &id010 !ruby/object:Gem::Requirement
147
163
  none: false
148
164
  requirements:
149
165
  - - ~>
@@ -154,10 +170,10 @@ dependencies:
154
170
  - 13
155
171
  - 6
156
172
  version: 0.13.6
157
- type: :runtime
158
- name: thor
173
+ requirement: *id010
159
174
  prerelease: false
160
- version_requirements: *id009
175
+ name: thor
176
+ type: :runtime
161
177
  description: Process manager for applications with multiple components
162
178
  email: |
163
179
  <ddollar@gmail.com>
@@ -173,6 +189,7 @@ files:
173
189
  - man/foreman.1
174
190
  - README.markdown
175
191
  - data/example/Procfile
192
+ - data/example/Procfile.without_colon
176
193
  - data/example/error
177
194
  - data/example/log/neverdie.log
178
195
  - data/example/ticker
@@ -185,6 +202,7 @@ files:
185
202
  - lib/foreman/export.rb
186
203
  - lib/foreman/export/base.rb
187
204
  - lib/foreman/export/inittab.rb
205
+ - lib/foreman/export/json.rb
188
206
  - lib/foreman/export/upstart.rb
189
207
  - lib/foreman/process.rb
190
208
  - lib/foreman/utils.rb
@@ -225,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
243
  requirements: []
226
244
 
227
245
  rubyforge_project: nowarning
228
- rubygems_version: 1.3.7
246
+ rubygems_version: 1.4.2
229
247
  signing_key:
230
248
  specification_version: 3
231
249
  summary: Process manager for applications with multiple components