foreman 0.39.0 → 0.41.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/README.md +1 -1
- data/data/export/supervisord/app.conf.erb +21 -0
- data/lib/foreman/cli.rb +1 -0
- data/lib/foreman/color.rb +40 -0
- data/lib/foreman/engine.rb +33 -52
- data/lib/foreman/export/supervisord.rb +26 -0
- data/lib/foreman/export.rb +2 -0
- data/lib/foreman/version.rb +1 -1
- data/lib/foreman.rb +0 -6
- data/man/foreman.1 +13 -3
- data/spec/foreman/cli_spec.rb +8 -0
- data/spec/foreman/color_spec.rb +31 -0
- data/spec/foreman/engine_spec.rb +16 -8
- data/spec/foreman/export/supervisord_spec.rb +75 -0
- data/spec/foreman_spec.rb +0 -18
- data/spec/resources/export/supervisord/app-alpha-2.conf +21 -0
- data/spec/resources/export/supervisord/app.conf +21 -0
- metadata +13 -17
data/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Manage Procfile-based applications
|
|
|
33
33
|
David Dollar
|
|
34
34
|
|
|
35
35
|
#### Patches contributed by
|
|
36
|
-
|
|
36
|
+
[Contributor List](https://github.com/ddollar/foreman/contributors)
|
|
37
37
|
|
|
38
38
|
## License
|
|
39
39
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%
|
|
2
|
+
engine.procfile.entries.each do |process|
|
|
3
|
+
next if (conc = self.concurrency[process.name]) < 1
|
|
4
|
+
1.upto(self.concurrency[process.name]) do |num|
|
|
5
|
+
port = engine.port_for(process, num, self.port)
|
|
6
|
+
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
|
+
%>
|
|
9
|
+
[program:<%= app %>-<%= name %>]
|
|
10
|
+
command=<%= process.command %>
|
|
11
|
+
autostart=true
|
|
12
|
+
autorestart=true
|
|
13
|
+
stopsignal=QUIT
|
|
14
|
+
stdout_logfile=<%= log_root %>/<%=process.name%>-<%=num%>-out.log
|
|
15
|
+
stderr_logfile=<%= log_root %>/<%=process.name%>-<%=num%>-err.log
|
|
16
|
+
user=<%= user %>
|
|
17
|
+
directory=<%= engine.directory %>
|
|
18
|
+
environment=<%= environment.join(',') %><%
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
%>
|
data/lib/foreman/cli.rb
CHANGED
|
@@ -54,6 +54,7 @@ class Foreman::CLI < Thor
|
|
|
54
54
|
desc "check", "Validate your application's Procfile"
|
|
55
55
|
|
|
56
56
|
def check
|
|
57
|
+
check_procfile!
|
|
57
58
|
error "no processes defined" unless engine.procfile.entries.length > 0
|
|
58
59
|
puts "valid procfile detected (#{engine.procfile.process_names.join(', ')})"
|
|
59
60
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require "foreman"
|
|
2
|
+
|
|
3
|
+
module Foreman::Color
|
|
4
|
+
|
|
5
|
+
ANSI = {
|
|
6
|
+
:reset => 0,
|
|
7
|
+
:black => 30,
|
|
8
|
+
:red => 31,
|
|
9
|
+
:green => 32,
|
|
10
|
+
:yellow => 33,
|
|
11
|
+
:blue => 34,
|
|
12
|
+
:magenta => 35,
|
|
13
|
+
:cyan => 36,
|
|
14
|
+
:white => 37,
|
|
15
|
+
:bright_black => 30,
|
|
16
|
+
:bright_red => 31,
|
|
17
|
+
:bright_green => 32,
|
|
18
|
+
:bright_yellow => 33,
|
|
19
|
+
:bright_blue => 34,
|
|
20
|
+
:bright_magenta => 35,
|
|
21
|
+
:bright_cyan => 36,
|
|
22
|
+
:bright_white => 37,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def self.enable(io)
|
|
26
|
+
io.extend(self)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def color?
|
|
30
|
+
return false unless self.respond_to?(:isatty)
|
|
31
|
+
self.isatty && ENV["TERM"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def color(name)
|
|
35
|
+
return "" unless color?
|
|
36
|
+
return "" unless ansi = ANSI[name.to_sym]
|
|
37
|
+
"\e[#{ansi}m"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
data/lib/foreman/engine.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
require "foreman"
|
|
2
|
+
require "foreman/color"
|
|
2
3
|
require "foreman/process"
|
|
3
4
|
require "foreman/procfile"
|
|
4
5
|
require "foreman/utils"
|
|
5
6
|
require "tempfile"
|
|
6
7
|
require "timeout"
|
|
7
|
-
require "term/ansicolor"
|
|
8
8
|
require "fileutils"
|
|
9
9
|
require "thread"
|
|
10
10
|
|
|
11
11
|
class Foreman::Engine
|
|
12
12
|
|
|
13
|
+
attr_reader :environment
|
|
13
14
|
attr_reader :procfile
|
|
14
15
|
attr_reader :directory
|
|
15
16
|
attr_reader :options
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
COLORS = %w( cyan yellow green magenta red blue intense_cyan intense_yellow
|
|
19
|
+
intense_green intense_magenta intense_red, intense_blue )
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
intense_cyan, intense_yellow, intense_green, intense_magenta,
|
|
21
|
-
intense_red, intense_blue ]
|
|
21
|
+
Foreman::Color.enable($stdout)
|
|
22
22
|
|
|
23
23
|
def initialize(procfile, options={})
|
|
24
24
|
@procfile = Foreman::Procfile.new(procfile)
|
|
@@ -28,11 +28,6 @@ class Foreman::Engine
|
|
|
28
28
|
@output_mutex = Mutex.new
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def self.load_env!(env_file)
|
|
32
|
-
@environment = read_environment_files(env_file)
|
|
33
|
-
apply_environment!
|
|
34
|
-
end
|
|
35
|
-
|
|
36
31
|
def start
|
|
37
32
|
proctitle "ruby: foreman master"
|
|
38
33
|
termtitle "#{File.basename(@directory)} - foreman"
|
|
@@ -52,6 +47,10 @@ class Foreman::Engine
|
|
|
52
47
|
base_port.to_i + offset + num - 1
|
|
53
48
|
end
|
|
54
49
|
|
|
50
|
+
def apply_environment!
|
|
51
|
+
environment.each { |k,v| ENV[k] = v }
|
|
52
|
+
end
|
|
53
|
+
|
|
55
54
|
private ######################################################################
|
|
56
55
|
|
|
57
56
|
def spawn_processes
|
|
@@ -128,11 +127,11 @@ private ######################################################################
|
|
|
128
127
|
rescue Errno::ECHILD
|
|
129
128
|
end
|
|
130
129
|
|
|
131
|
-
def info(message, name="system", color
|
|
130
|
+
def info(message, name="system", color=:white)
|
|
132
131
|
output = ""
|
|
133
|
-
output += color
|
|
132
|
+
output += $stdout.color(color)
|
|
134
133
|
output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "
|
|
135
|
-
output +=
|
|
134
|
+
output += $stdout.color(:reset)
|
|
136
135
|
output += message.chomp
|
|
137
136
|
puts output
|
|
138
137
|
end
|
|
@@ -182,8 +181,8 @@ private ######################################################################
|
|
|
182
181
|
end
|
|
183
182
|
|
|
184
183
|
def assign_colors
|
|
185
|
-
procfile.entries.
|
|
186
|
-
colors[entry.name] =
|
|
184
|
+
procfile.entries.each_with_index do |entry, idx|
|
|
185
|
+
colors[entry.name] = COLORS[idx % COLORS.length]
|
|
187
186
|
end
|
|
188
187
|
end
|
|
189
188
|
|
|
@@ -191,49 +190,31 @@ private ######################################################################
|
|
|
191
190
|
readers.invert[reader]
|
|
192
191
|
end
|
|
193
192
|
|
|
194
|
-
def
|
|
195
|
-
|
|
196
|
-
@current_color += 1
|
|
197
|
-
@current_color = 0 if COLORS.length < @current_color
|
|
198
|
-
COLORS[@current_color]
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
module Env
|
|
202
|
-
attr_reader :environment
|
|
193
|
+
def read_environment_files(filenames)
|
|
194
|
+
environment = {}
|
|
203
195
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
(filenames || "").split(",").map(&:strip).each do |filename|
|
|
208
|
-
error "No such file: #{filename}" unless File.exists?(filename)
|
|
209
|
-
environment.merge!(read_environment(filename))
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
environment.merge!(read_environment(".env")) unless filenames
|
|
213
|
-
environment
|
|
196
|
+
(filenames || "").split(",").map(&:strip).each do |filename|
|
|
197
|
+
error "No such file: #{filename}" unless File.exists?(filename)
|
|
198
|
+
environment.merge!(read_environment(filename))
|
|
214
199
|
end
|
|
215
200
|
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
environment.merge!(read_environment(".env")) unless filenames
|
|
202
|
+
environment
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def read_environment(filename)
|
|
206
|
+
return {} unless File.exists?(filename)
|
|
218
207
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
|
222
215
|
end
|
|
223
|
-
hash
|
|
224
216
|
end
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
def apply_environment!
|
|
228
|
-
@environment.each { |k,v| ENV[k] = v }
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
def error(message)
|
|
232
|
-
puts "ERROR: #{message}"
|
|
233
|
-
exit 1
|
|
217
|
+
hash
|
|
234
218
|
end
|
|
235
219
|
end
|
|
236
|
-
|
|
237
|
-
include Env
|
|
238
|
-
extend Env
|
|
239
220
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "erb"
|
|
2
|
+
require "foreman/export"
|
|
3
|
+
|
|
4
|
+
class Foreman::Export::Supervisord < Foreman::Export::Base
|
|
5
|
+
|
|
6
|
+
def export
|
|
7
|
+
error("Must specify a location") unless location
|
|
8
|
+
|
|
9
|
+
FileUtils.mkdir_p location
|
|
10
|
+
|
|
11
|
+
app = self.app || File.basename(engine.directory)
|
|
12
|
+
user = self.user || app
|
|
13
|
+
log_root = self.log || "/var/log/#{app}"
|
|
14
|
+
template_root = self.template
|
|
15
|
+
|
|
16
|
+
Dir["#{location}/#{app}*.conf"].each do |file|
|
|
17
|
+
say "cleaning up: #{file}"
|
|
18
|
+
FileUtils.rm(file)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
app_template = export_template("supervisord", "app.conf.erb", template_root)
|
|
22
|
+
app_config = ERB.new(app_template, 0, '<').result(binding)
|
|
23
|
+
write_file "#{location}/#{app}.conf", app_config
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
data/lib/foreman/export.rb
CHANGED
data/lib/foreman/version.rb
CHANGED
data/lib/foreman.rb
CHANGED
|
@@ -4,12 +4,6 @@ module Foreman
|
|
|
4
4
|
|
|
5
5
|
class AppDoesNotExist < Exception; end
|
|
6
6
|
|
|
7
|
-
# load contents of env_file into ENV
|
|
8
|
-
def self.load_env!(env_file = './.env')
|
|
9
|
-
require 'foreman/engine'
|
|
10
|
-
Foreman::Engine.load_env!(env_file)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
7
|
def self.runner
|
|
14
8
|
File.expand_path("../../bin/foreman-runner", __FILE__)
|
|
15
9
|
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" "
|
|
4
|
+
.TH "FOREMAN" "1" "February 2012" "Foreman 0.39.0" "Foreman Manual"
|
|
5
5
|
.
|
|
6
6
|
.SH "NAME"
|
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
\fBforeman start [process]\fR
|
|
11
11
|
.
|
|
12
12
|
.br
|
|
13
|
+
\fBforeman run <command>\fR
|
|
14
|
+
.
|
|
15
|
+
.br
|
|
13
16
|
\fBforeman export <format> [location]\fR
|
|
14
17
|
.
|
|
15
18
|
.SH "DESCRIPTION"
|
|
16
|
-
|
|
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\.
|
|
17
20
|
.
|
|
18
21
|
.SH "RUNNING"
|
|
19
22
|
\fBforeman start\fR is used to run your application directly from the command line\.
|
|
@@ -35,6 +38,9 @@ Specify the number of each process type to run\. The value passed in should be i
|
|
|
35
38
|
\fB\-p\fR, \fB\-\-port\fR
|
|
36
39
|
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
|
37
40
|
.
|
|
41
|
+
.P
|
|
42
|
+
\fBforeman run\fR is used to run one\-off commands using the same environment as your defined processes\.
|
|
43
|
+
.
|
|
38
44
|
.SH "EXPORTING"
|
|
39
45
|
\fBforeman export\fR is used to export your application to another process management format\.
|
|
40
46
|
.
|
|
@@ -61,10 +67,14 @@ Specify the directory to place process logs in\.
|
|
|
61
67
|
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
|
62
68
|
.
|
|
63
69
|
.TP
|
|
70
|
+
\fB\-t\fR, \fB\-\-template\fR
|
|
71
|
+
Specify an alternate template to use for creating export files\. See \fIhttps://github\.com/ddollar/foreman/tree/master/data/export\fR for examples\.
|
|
72
|
+
.
|
|
73
|
+
.TP
|
|
64
74
|
\fB\-u\fR, \fB\-\-user\fR
|
|
65
75
|
Specify the user the application should be run as\. Defaults to the app name
|
|
66
76
|
.
|
|
67
|
-
.SH "OPTIONS"
|
|
77
|
+
.SH "GLOBAL OPTIONS"
|
|
68
78
|
These options control all modes of foreman\'s operation\.
|
|
69
79
|
.
|
|
70
80
|
.TP
|
data/spec/foreman/cli_spec.rb
CHANGED
|
@@ -120,6 +120,14 @@ describe "Foreman::CLI", :fakefs do
|
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
|
+
|
|
124
|
+
describe "without a Procfile" do
|
|
125
|
+
it "displays an error" do
|
|
126
|
+
mock_error(subject, "Procfile does not exist.") do
|
|
127
|
+
subject.check
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
123
131
|
end
|
|
124
132
|
|
|
125
133
|
describe "run" do
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "foreman/color"
|
|
3
|
+
|
|
4
|
+
describe Foreman::Color do
|
|
5
|
+
|
|
6
|
+
let(:io) { Object.new }
|
|
7
|
+
|
|
8
|
+
it "should extend an object with colorization" do
|
|
9
|
+
Foreman::Color.enable(io)
|
|
10
|
+
io.should respond_to(:color)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should not colorize if the object does not respond to isatty" do
|
|
14
|
+
mock(io).respond_to?(:isatty) { false }
|
|
15
|
+
Foreman::Color.enable(io)
|
|
16
|
+
io.color(:white).should == ""
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should not colorize if the object is not a tty" do
|
|
20
|
+
mock(io).isatty { false }
|
|
21
|
+
Foreman::Color.enable(io)
|
|
22
|
+
io.color(:white).should == ""
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should colorize if the object is a tty" do
|
|
26
|
+
mock(io).isatty { true }
|
|
27
|
+
Foreman::Color.enable(io)
|
|
28
|
+
io.color(:white).should == "\e[37m"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
data/spec/foreman/engine_spec.rb
CHANGED
|
@@ -53,14 +53,16 @@ describe "Foreman::Engine", :fakefs do
|
|
|
53
53
|
before(:each) do
|
|
54
54
|
write_procfile
|
|
55
55
|
stub(Process).fork
|
|
56
|
+
any_instance_of(Foreman::Engine) do |engine|
|
|
57
|
+
stub(engine).info
|
|
58
|
+
stub(engine).spawn_processes
|
|
59
|
+
stub(engine).watch_for_termination
|
|
60
|
+
end
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
it "should read if specified" do
|
|
59
64
|
File.open("/tmp/env", "w") { |f| f.puts("FOO=baz") }
|
|
60
65
|
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
|
61
|
-
stub(engine).info
|
|
62
|
-
mock(engine).spawn_processes
|
|
63
|
-
mock(engine).watch_for_termination
|
|
64
66
|
engine.environment.should == {"FOO"=>"baz"}
|
|
65
67
|
engine.start
|
|
66
68
|
end
|
|
@@ -69,13 +71,21 @@ describe "Foreman::Engine", :fakefs do
|
|
|
69
71
|
File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
|
|
70
72
|
File.open("/tmp/env2", "w") { |f| f.puts("BAZ=qux") }
|
|
71
73
|
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env1,/tmp/env2")
|
|
72
|
-
stub(engine).info
|
|
73
|
-
mock(engine).spawn_processes
|
|
74
|
-
mock(engine).watch_for_termination
|
|
75
74
|
engine.environment.should == { "FOO"=>"bar", "BAZ"=>"qux" }
|
|
76
75
|
engine.start
|
|
77
76
|
end
|
|
78
77
|
|
|
78
|
+
it "should handle quoted values" do
|
|
79
|
+
File.open("/tmp/env", "w") do |f|
|
|
80
|
+
f.puts 'FOO=bar'
|
|
81
|
+
f.puts 'BAZ="qux"'
|
|
82
|
+
f.puts "FRED='barney'"
|
|
83
|
+
f.puts 'OTHER="escaped\"quote"'
|
|
84
|
+
end
|
|
85
|
+
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
|
86
|
+
engine.environment.should == { "FOO" => "bar", "BAZ" => "qux", "FRED" => "barney", "OTHER" => 'escaped"quote' }
|
|
87
|
+
end
|
|
88
|
+
|
|
79
89
|
it "should fail if specified and doesnt exist" do
|
|
80
90
|
mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
|
|
81
91
|
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
|
@@ -84,8 +94,6 @@ describe "Foreman::Engine", :fakefs do
|
|
|
84
94
|
it "should read .env if none specified" do
|
|
85
95
|
File.open(".env", "w") { |f| f.puts("FOO=qoo") }
|
|
86
96
|
engine = Foreman::Engine.new("Procfile")
|
|
87
|
-
mock(engine).spawn_processes
|
|
88
|
-
mock(engine).watch_for_termination
|
|
89
97
|
engine.environment.should == {"FOO"=>"qoo"}
|
|
90
98
|
engine.start
|
|
91
99
|
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "foreman/engine"
|
|
3
|
+
require "foreman/export/supervisord"
|
|
4
|
+
require "tmpdir"
|
|
5
|
+
|
|
6
|
+
describe Foreman::Export::Supervisord, :fakefs do
|
|
7
|
+
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
|
8
|
+
let(:engine) { Foreman::Engine.new(procfile) }
|
|
9
|
+
let(:options) { Hash.new }
|
|
10
|
+
let(:supervisord) { Foreman::Export::Supervisord.new("/tmp/init", engine, options) }
|
|
11
|
+
|
|
12
|
+
before(:each) { load_export_templates_into_fakefs("supervisord") }
|
|
13
|
+
before(:each) { stub(supervisord).say }
|
|
14
|
+
|
|
15
|
+
it "exports to the filesystem" do
|
|
16
|
+
supervisord.export
|
|
17
|
+
|
|
18
|
+
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "cleans up if exporting into an existing dir" do
|
|
22
|
+
mock(FileUtils).rm("/tmp/init/app.conf")
|
|
23
|
+
|
|
24
|
+
supervisord.export
|
|
25
|
+
supervisord.export
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "with concurrency" do
|
|
29
|
+
let(:options) { Hash[:concurrency => "alpha=2"] }
|
|
30
|
+
|
|
31
|
+
it "exports to the filesystem with concurrency" do
|
|
32
|
+
supervisord.export
|
|
33
|
+
|
|
34
|
+
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "with alternate templates" do
|
|
39
|
+
let(:template_root) { "/tmp/alternate" }
|
|
40
|
+
let(:supervisord) { Foreman::Export::Supervisord.new("/tmp/init", engine, :template => template_root) }
|
|
41
|
+
|
|
42
|
+
before do
|
|
43
|
+
FileUtils.mkdir_p template_root
|
|
44
|
+
File.open("#{template_root}/app.conf.erb", "w") { |f| f.puts "alternate_template" }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "can export with alternate template files" do
|
|
48
|
+
supervisord.export
|
|
49
|
+
|
|
50
|
+
File.read("/tmp/init/app.conf").should == "alternate_template\n"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "with alternate templates from home dir" do
|
|
55
|
+
let(:default_template_root) {File.expand_path("#{ENV['HOME']}/.foreman/templates")}
|
|
56
|
+
|
|
57
|
+
before do
|
|
58
|
+
ENV['_FOREMAN_SPEC_HOME'] = ENV['HOME']
|
|
59
|
+
ENV['HOME'] = "/home/appuser"
|
|
60
|
+
FileUtils.mkdir_p default_template_root
|
|
61
|
+
File.open("#{default_template_root}/app.conf.erb", "w") { |f| f.puts "default_alternate_template" }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
after do
|
|
65
|
+
ENV['HOME'] = ENV.delete('_FOREMAN_SPEC_HOME')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "can export with alternate template files" do
|
|
69
|
+
supervisord.export
|
|
70
|
+
|
|
71
|
+
File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
data/spec/foreman_spec.rb
CHANGED
|
@@ -8,24 +8,6 @@ describe Foreman do
|
|
|
8
8
|
it { should be_a String }
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
describe "::load_env!(env_file)", :fakefs do
|
|
12
|
-
after do
|
|
13
|
-
ENV['FOO'] = nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should load env_file into ENV" do
|
|
17
|
-
File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
|
|
18
|
-
Foreman.load_env!("/tmp/env1")
|
|
19
|
-
ENV['FOO'].should == 'bar'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should assume env_file in ./.env" do
|
|
23
|
-
File.open("./.env", "w") { |f| f.puts("FOO=bar") }
|
|
24
|
-
Foreman.load_env!
|
|
25
|
-
ENV['FOO'].should == 'bar'
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
11
|
describe "runner" do
|
|
30
12
|
it "should exist" do
|
|
31
13
|
File.exists?(Foreman.runner).should == true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
[program:app-alpha-1]
|
|
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=PORT=5000
|
|
12
|
+
[program:app-alpha-2]
|
|
13
|
+
command=./alpha
|
|
14
|
+
autostart=true
|
|
15
|
+
autorestart=true
|
|
16
|
+
stopsignal=QUIT
|
|
17
|
+
stdout_logfile=/var/log/app/alpha-2-out.log
|
|
18
|
+
stderr_logfile=/var/log/app/alpha-2-err.log
|
|
19
|
+
user=app
|
|
20
|
+
directory=/tmp/app
|
|
21
|
+
environment=PORT=5001
|
|
@@ -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=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=PORT=5100
|
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.
|
|
4
|
+
version: 0.41.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,22 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
-
- !ruby/object:Gem::Dependency
|
|
15
|
-
name: term-ansicolor
|
|
16
|
-
requirement: &70337643431700 !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
|
-
requirements:
|
|
19
|
-
- - ~>
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: 1.0.7
|
|
22
|
-
type: :runtime
|
|
23
|
-
prerelease: false
|
|
24
|
-
version_requirements: *70337643431700
|
|
25
14
|
- !ruby/object:Gem::Dependency
|
|
26
15
|
name: thor
|
|
27
|
-
requirement: &
|
|
16
|
+
requirement: &70166560574240 !ruby/object:Gem::Requirement
|
|
28
17
|
none: false
|
|
29
18
|
requirements:
|
|
30
19
|
- - ! '>='
|
|
@@ -32,7 +21,7 @@ dependencies:
|
|
|
32
21
|
version: 0.13.6
|
|
33
22
|
type: :runtime
|
|
34
23
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70166560574240
|
|
36
25
|
description: Process manager for applications with multiple components
|
|
37
26
|
email: ddollar@gmail.com
|
|
38
27
|
executables:
|
|
@@ -51,16 +40,19 @@ files:
|
|
|
51
40
|
- data/export/bluepill/master.pill.erb
|
|
52
41
|
- data/export/runit/log_run.erb
|
|
53
42
|
- data/export/runit/run.erb
|
|
43
|
+
- data/export/supervisord/app.conf.erb
|
|
54
44
|
- data/export/upstart/master.conf.erb
|
|
55
45
|
- data/export/upstart/process.conf.erb
|
|
56
46
|
- data/export/upstart/process_master.conf.erb
|
|
57
47
|
- lib/foreman/cli.rb
|
|
48
|
+
- lib/foreman/color.rb
|
|
58
49
|
- lib/foreman/distribution.rb
|
|
59
50
|
- lib/foreman/engine.rb
|
|
60
51
|
- lib/foreman/export/base.rb
|
|
61
52
|
- lib/foreman/export/bluepill.rb
|
|
62
53
|
- lib/foreman/export/inittab.rb
|
|
63
54
|
- lib/foreman/export/runit.rb
|
|
55
|
+
- lib/foreman/export/supervisord.rb
|
|
64
56
|
- lib/foreman/export/upstart.rb
|
|
65
57
|
- lib/foreman/export.rb
|
|
66
58
|
- lib/foreman/helpers.rb
|
|
@@ -72,11 +64,13 @@ files:
|
|
|
72
64
|
- lib/foreman.rb
|
|
73
65
|
- README.md
|
|
74
66
|
- spec/foreman/cli_spec.rb
|
|
67
|
+
- spec/foreman/color_spec.rb
|
|
75
68
|
- spec/foreman/engine_spec.rb
|
|
76
69
|
- spec/foreman/export/base_spec.rb
|
|
77
70
|
- spec/foreman/export/bluepill_spec.rb
|
|
78
71
|
- spec/foreman/export/inittab_spec.rb
|
|
79
72
|
- spec/foreman/export/runit_spec.rb
|
|
73
|
+
- spec/foreman/export/supervisord_spec.rb
|
|
80
74
|
- spec/foreman/export/upstart_spec.rb
|
|
81
75
|
- spec/foreman/export_spec.rb
|
|
82
76
|
- spec/foreman/helpers_spec.rb
|
|
@@ -94,6 +88,8 @@ files:
|
|
|
94
88
|
- spec/resources/export/runit/app-alpha-2-run
|
|
95
89
|
- spec/resources/export/runit/app-bravo-1-log-run
|
|
96
90
|
- spec/resources/export/runit/app-bravo-1-run
|
|
91
|
+
- spec/resources/export/supervisord/app-alpha-2.conf
|
|
92
|
+
- spec/resources/export/supervisord/app.conf
|
|
97
93
|
- spec/resources/export/upstart/app-alpha-1.conf
|
|
98
94
|
- spec/resources/export/upstart/app-alpha-2.conf
|
|
99
95
|
- spec/resources/export/upstart/app-alpha.conf
|
|
@@ -116,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
116
112
|
version: '0'
|
|
117
113
|
segments:
|
|
118
114
|
- 0
|
|
119
|
-
hash:
|
|
115
|
+
hash: 4054055636504419796
|
|
120
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
117
|
none: false
|
|
122
118
|
requirements:
|
|
@@ -125,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
121
|
version: '0'
|
|
126
122
|
segments:
|
|
127
123
|
- 0
|
|
128
|
-
hash:
|
|
124
|
+
hash: 4054055636504419796
|
|
129
125
|
requirements: []
|
|
130
126
|
rubyforge_project:
|
|
131
127
|
rubygems_version: 1.8.11
|