foreman 0.41.0 → 0.43.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.
@@ -1,12 +1,15 @@
1
1
  <%
2
+ app_names = []
2
3
  engine.procfile.entries.each do |process|
3
4
  next if (conc = self.concurrency[process.name]) < 1
4
5
  1.upto(self.concurrency[process.name]) do |num|
5
6
  port = engine.port_for(process, num, self.port)
6
7
  name = if (conc > 1); "#{process.name}-#{num}" else process.name; end
7
- environment = (engine.environment.each_pair { |var,env| "#{var.upcase}=#{env}" }.to_a << "PORT=#{port}")
8
+ environment = (engine.environment.map{ |var,env| %{#{var.upcase}="#{env}"} } + [%{PORT="#{port}"}])
9
+ app_name = "#{app}-#{name}"
10
+ app_names << app_name
8
11
  %>
9
- [program:<%= app %>-<%= name %>]
12
+ [program:<%= app_name %>]
10
13
  command=<%= process.command %>
11
14
  autostart=true
12
15
  autorestart=true
@@ -18,4 +21,7 @@ directory=<%= engine.directory %>
18
21
  environment=<%= environment.join(',') %><%
19
22
  end
20
23
  end
21
- %>
24
+ %>
25
+
26
+ [group:<%= app %>]
27
+ programs=<%= app_names.join(',') %>
@@ -51,6 +51,22 @@ class Foreman::Engine
51
51
  environment.each { |k,v| ENV[k] = v }
52
52
  end
53
53
 
54
+ def self.read_environment(filename)
55
+ return {} unless File.exists?(filename)
56
+
57
+ File.read(filename).split("\n").inject({}) do |hash, line|
58
+ if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
59
+ key, val = [$1, $2]
60
+ case val
61
+ when /\A'(.*)'\z/ then hash[key] = $1
62
+ when /\A"(.*)"\z/ then hash[key] = $1.gsub(/\\(.)/, '\1')
63
+ else hash[key] = val
64
+ end
65
+ end
66
+ hash
67
+ end
68
+ end
69
+
54
70
  private ######################################################################
55
71
 
56
72
  def spawn_processes
@@ -195,26 +211,10 @@ private ######################################################################
195
211
 
196
212
  (filenames || "").split(",").map(&:strip).each do |filename|
197
213
  error "No such file: #{filename}" unless File.exists?(filename)
198
- environment.merge!(read_environment(filename))
214
+ environment.merge!(Foreman::Engine.read_environment(filename))
199
215
  end
200
216
 
201
- environment.merge!(read_environment(".env")) unless filenames
217
+ environment.merge!(Foreman::Engine.read_environment(".env")) unless filenames
202
218
  environment
203
219
  end
204
-
205
- def read_environment(filename)
206
- return {} unless File.exists?(filename)
207
-
208
- File.read(filename).split("\n").inject({}) do |hash, line|
209
- if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
210
- key, val = [$1, $2]
211
- case val
212
- when /\A'(.*)'\z/ then hash[key] = $1
213
- when /\A"(.*)"\z/ then hash[key] = $1.gsub(/\\(.)/, '\1')
214
- else hash[key] = val
215
- end
216
- end
217
- hash
218
- end
219
- end
220
220
  end
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.41.0"
3
+ VERSION = "0.43.0"
4
4
 
5
5
  end
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" "February 2012" "Foreman 0.39.0" "Foreman Manual"
4
+ .TH "FOREMAN" "1" "February 2012" "Foreman 0.42.0" "Foreman Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBforeman\fR \- manage Procfile\-based applications
@@ -15,12 +15,11 @@ describe Foreman::Export::Supervisord, :fakefs do
15
15
  it "exports to the filesystem" do
16
16
  supervisord.export
17
17
 
18
- File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
18
+ File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
19
19
  end
20
20
 
21
21
  it "cleans up if exporting into an existing dir" do
22
22
  mock(FileUtils).rm("/tmp/init/app.conf")
23
-
24
23
  supervisord.export
25
24
  supervisord.export
26
25
  end
@@ -30,8 +29,7 @@ describe Foreman::Export::Supervisord, :fakefs do
30
29
 
31
30
  it "exports to the filesystem with concurrency" do
32
31
  supervisord.export
33
-
34
- File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf")
32
+ File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf")
35
33
  end
36
34
  end
37
35
 
@@ -46,7 +44,6 @@ describe Foreman::Export::Supervisord, :fakefs do
46
44
 
47
45
  it "can export with alternate template files" do
48
46
  supervisord.export
49
-
50
47
  File.read("/tmp/init/app.conf").should == "alternate_template\n"
51
48
  end
52
49
  end
@@ -67,9 +64,22 @@ describe Foreman::Export::Supervisord, :fakefs do
67
64
 
68
65
  it "can export with alternate template files" do
69
66
  supervisord.export
70
-
71
67
  File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
72
68
  end
73
69
  end
74
70
 
71
+ context "environment export" do
72
+ it "correctly translates environment when exporting" do
73
+ File.open("/tmp/supervisord_env", "w") { |f| f.puts("QUEUE=fastqueue,slowqueue\nVERBOSE=1") }
74
+
75
+ engine = Foreman::Engine.new(procfile,:env => "/tmp/supervisord_env")
76
+ supervisor = Foreman::Export::Supervisord.new("/tmp/init", engine, options)
77
+ stub(supervisor).say
78
+
79
+ supervisor.export
80
+
81
+ File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-env-with-comma.conf")
82
+ end
83
+ end
84
+
75
85
  end
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1-out.log
8
8
  stderr_logfile=/var/log/app/alpha-1-err.log
9
9
  user=app
10
10
  directory=/tmp/app
11
- environment=PORT=5000
11
+ environment=PORT="5000"
12
12
  [program:app-alpha-2]
13
13
  command=./alpha
14
14
  autostart=true
@@ -18,4 +18,7 @@ stdout_logfile=/var/log/app/alpha-2-out.log
18
18
  stderr_logfile=/var/log/app/alpha-2-err.log
19
19
  user=app
20
20
  directory=/tmp/app
21
- environment=PORT=5001
21
+ environment=PORT="5001"
22
+
23
+ [group:app]
24
+ programs=app-alpha-1,app-alpha-2
@@ -0,0 +1,24 @@
1
+
2
+ [program:app-alpha]
3
+ command=./alpha
4
+ autostart=true
5
+ autorestart=true
6
+ stopsignal=QUIT
7
+ stdout_logfile=/var/log/app/alpha-1-out.log
8
+ stderr_logfile=/var/log/app/alpha-1-err.log
9
+ user=app
10
+ directory=/tmp/app
11
+ environment=QUEUE="fastqueue,slowqueue",VERBOSE="1",PORT="5000"
12
+ [program:app-bravo]
13
+ command=./bravo
14
+ autostart=true
15
+ autorestart=true
16
+ stopsignal=QUIT
17
+ stdout_logfile=/var/log/app/bravo-1-out.log
18
+ stderr_logfile=/var/log/app/bravo-1-err.log
19
+ user=app
20
+ directory=/tmp/app
21
+ environment=QUEUE="fastqueue,slowqueue",VERBOSE="1",PORT="5100"
22
+
23
+ [group:app]
24
+ programs=app-alpha,app-bravo
@@ -0,0 +1,21 @@
1
+
2
+ [program:app-alpha]
3
+ command=./alpha
4
+ autostart=true
5
+ autorestart=true
6
+ stopsignal=QUIT
7
+ stdout_logfile=/var/log/app/alpha-1-out.log
8
+ stderr_logfile=/var/log/app/alpha-1-err.log
9
+ user=app
10
+ directory=/tmp/app
11
+ environment=FOO="bar",PORT="5000"
12
+ [program:app-bravo]
13
+ command=./bravo
14
+ autostart=true
15
+ autorestart=true
16
+ stopsignal=QUIT
17
+ stdout_logfile=/var/log/app/bravo-1-out.log
18
+ stderr_logfile=/var/log/app/bravo-1-err.log
19
+ user=app
20
+ directory=/tmp/app
21
+ environment=FOO="bar",PORT="5100"
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1-out.log
8
8
  stderr_logfile=/var/log/app/alpha-1-err.log
9
9
  user=app
10
10
  directory=/tmp/app
11
- environment=PORT=5000
11
+ environment=PORT="5000"
12
12
  [program:app-bravo]
13
13
  command=./bravo
14
14
  autostart=true
@@ -18,4 +18,7 @@ stdout_logfile=/var/log/app/bravo-1-out.log
18
18
  stderr_logfile=/var/log/app/bravo-1-err.log
19
19
  user=app
20
20
  directory=/tmp/app
21
- environment=PORT=5100
21
+ environment=PORT="5100"
22
+
23
+ [group:app]
24
+ programs=app-alpha,app-bravo
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.43.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-16 00:00:00.000000000 Z
12
+ date: 2012-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70166560574240 !ruby/object:Gem::Requirement
16
+ requirement: &70234170306080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.13.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70166560574240
24
+ version_requirements: *70234170306080
25
25
  description: Process manager for applications with multiple components
26
26
  email: ddollar@gmail.com
27
27
  executables:
@@ -89,6 +89,8 @@ files:
89
89
  - spec/resources/export/runit/app-bravo-1-log-run
90
90
  - spec/resources/export/runit/app-bravo-1-run
91
91
  - spec/resources/export/supervisord/app-alpha-2.conf
92
+ - spec/resources/export/supervisord/app-env-with-comma.conf
93
+ - spec/resources/export/supervisord/app-env.conf
92
94
  - spec/resources/export/supervisord/app.conf
93
95
  - spec/resources/export/upstart/app-alpha-1.conf
94
96
  - spec/resources/export/upstart/app-alpha-2.conf
@@ -110,18 +112,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
112
  - - ! '>='
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
- segments:
114
- - 0
115
- hash: 4054055636504419796
116
115
  required_rubygems_version: !ruby/object:Gem::Requirement
117
116
  none: false
118
117
  requirements:
119
118
  - - ! '>='
120
119
  - !ruby/object:Gem::Version
121
120
  version: '0'
122
- segments:
123
- - 0
124
- hash: 4054055636504419796
125
121
  requirements: []
126
122
  rubyforge_project:
127
123
  rubygems_version: 1.8.11