foreman 0.37.0.pre5-java → 0.37.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/data/example/Procfile +1 -0
- data/data/example/utf8 +11 -0
- data/lib/foreman/cli.rb +3 -22
- data/lib/foreman/engine.rb +28 -16
- data/lib/foreman/export.rb +21 -0
- data/lib/foreman/export/inittab.rb +4 -4
- data/lib/foreman/helpers.rb +2 -7
- data/lib/foreman/process.rb +1 -1
- data/lib/foreman/version.rb +1 -1
- data/man/foreman.1 +1 -1
- data/spec/foreman/cli_spec.rb +21 -4
- data/spec/foreman/engine_spec.rb +19 -0
- data/spec/foreman/export/base_spec.rb +22 -0
- data/spec/foreman/export/bluepill_spec.rb +8 -1
- data/spec/foreman/export/inittab_spec.rb +40 -0
- data/spec/foreman/export/upstart_spec.rb +11 -0
- data/spec/foreman/export_spec.rb +22 -0
- data/spec/foreman/helpers_spec.rb +26 -0
- data/spec/foreman/process_spec.rb +1 -1
- data/spec/foreman_spec.rb +6 -0
- data/spec/resources/bin/utf8 +2 -0
- data/spec/resources/export/inittab/inittab.concurrency +4 -0
- data/spec/resources/export/inittab/inittab.default +4 -0
- data/spec/spec_helper.rb +19 -3
- metadata +19 -12
data/README.md
CHANGED
@@ -25,6 +25,7 @@ Manage Procfile-based applications
|
|
25
25
|
|
26
26
|
* [man page](http://ddollar.github.com/foreman)
|
27
27
|
* [wiki](http://github.com/ddollar/foreman/wiki)
|
28
|
+
* [changelog](https://github.com/ddollar/foreman/blob/master/Changelog.md)
|
28
29
|
|
29
30
|
## Authors
|
30
31
|
|
@@ -32,7 +33,7 @@ Manage Procfile-based applications
|
|
32
33
|
David Dollar
|
33
34
|
|
34
35
|
#### Patches contributed by
|
35
|
-
Adam Wiggins, Chris Continanza, Chris Lowder, Craig R Webster, Dan Farina, Dan Peterson, David Dollar, Fletcher Nichol, Gabriel Burt, Gamaliel Toro, Greg Reinacker, Hugues Le Gendre, Hunter Nield, Iain Hecker, Jay Zeschin, Keith Rarick, Khaja Minhajuddin, Lincoln Stoll, Marcos Muino Garcia, Mark McGranaghan, Matt Griffin, Matt Haynes, Matthijs Langenberg, Michael Dwan, Michael van Rooijen, Mike Javorski, Nathan Broadbent, Nathan L Smith, Nick Zadrozny, Phil Hagelberg, Ricardo Chimal, Jr, Thom May, Tom Ward, brainopia, clifff, jc00ke
|
36
|
+
Adam Wiggins, Chris Continanza, Chris Lowder, Craig R Webster, Dan Farina, Dan Peterson, David Dollar, Fletcher Nichol, Florian Apolloner, Gabriel Burt, Gamaliel Toro, Greg Reinacker, Hugues Le Gendre, Hunter Nield, Iain Hecker, Jay Zeschin, Keith Rarick, Khaja Minhajuddin, Lincoln Stoll, Marcos Muino Garcia, Mark McGranaghan, Matt Griffin, Matt Haynes, Matthijs Langenberg, Michael Dwan, Michael van Rooijen, Mike Javorski, Nathan Broadbent, Nathan L Smith, Nick Zadrozny, Phil Hagelberg, Ricardo Chimal, Jr, Thom May, Tom Ward, brainopia, clifff, jc00ke
|
36
37
|
|
37
38
|
## License
|
38
39
|
|
data/data/example/Procfile
CHANGED
data/data/example/utf8
ADDED
data/lib/foreman/cli.rb
CHANGED
@@ -40,22 +40,11 @@ class Foreman::CLI < Thor
|
|
40
40
|
method_option :port, :type => :numeric, :aliases => "-p"
|
41
41
|
method_option :user, :type => :string, :aliases => "-u"
|
42
42
|
method_option :template, :type => :string, :aliases => "-t"
|
43
|
-
method_option :concurrency, :type => :string, :aliases => "-c",
|
44
|
-
:banner => '"alpha=5,bar=3"'
|
43
|
+
method_option :concurrency, :type => :string, :aliases => "-c", :banner => '"alpha=5,bar=3"'
|
45
44
|
|
46
45
|
def export(format, location=nil)
|
47
46
|
check_procfile!
|
48
|
-
|
49
|
-
begin
|
50
|
-
require "foreman/export/#{ format.tr('-', '_') }"
|
51
|
-
classy_format = classify(format)
|
52
|
-
formatter = constantize("Foreman::Export::#{ classy_format }")
|
53
|
-
rescue NameError => ex
|
54
|
-
error "Unknown export format: #{format} (no class Foreman::Export::#{ classy_format })."
|
55
|
-
rescue LoadError => ex
|
56
|
-
error "Unknown export format: #{format} (unable to load file 'foreman/export/#{ format.tr('-', '_') }')."
|
57
|
-
end
|
58
|
-
|
47
|
+
formatter = Foreman::Export.formatter(format)
|
59
48
|
formatter.new(location, engine, options).export
|
60
49
|
rescue Foreman::Export::Exception => ex
|
61
50
|
error ex.message
|
@@ -65,7 +54,7 @@ class Foreman::CLI < Thor
|
|
65
54
|
|
66
55
|
def check
|
67
56
|
error "no processes defined" unless engine.procfile.entries.length > 0
|
68
|
-
|
57
|
+
puts "valid procfile detected (#{engine.procfile.process_names.join(', ')})"
|
69
58
|
end
|
70
59
|
|
71
60
|
desc "run COMMAND", "Run a command using your application's environment"
|
@@ -95,19 +84,11 @@ private ######################################################################
|
|
95
84
|
options[:procfile] || "Procfile"
|
96
85
|
end
|
97
86
|
|
98
|
-
def display(message)
|
99
|
-
puts message
|
100
|
-
end
|
101
|
-
|
102
87
|
def error(message)
|
103
88
|
puts "ERROR: #{message}"
|
104
89
|
exit 1
|
105
90
|
end
|
106
91
|
|
107
|
-
def procfile_exists?(procfile)
|
108
|
-
File.exist?(procfile)
|
109
|
-
end
|
110
|
-
|
111
92
|
def options
|
112
93
|
original_options = super
|
113
94
|
return original_options unless File.exists?(".foreman")
|
data/lib/foreman/engine.rb
CHANGED
@@ -58,7 +58,7 @@ private ######################################################################
|
|
58
58
|
concurrency = Foreman::Utils.parse_concurrency(@options[:concurrency])
|
59
59
|
|
60
60
|
procfile.entries.each do |entry|
|
61
|
-
reader, writer = IO.pipe
|
61
|
+
reader, writer = (IO.method(:pipe).arity == 0 ? IO.pipe : IO.pipe("BINARY"))
|
62
62
|
entry.spawn(concurrency[entry.name], writer, @directory, @environment, port_for(entry, 1, base_port)).each do |process|
|
63
63
|
running_processes[process.pid] = process
|
64
64
|
readers[process] = reader
|
@@ -78,27 +78,39 @@ private ######################################################################
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def terminate_gracefully
|
81
|
+
return if @terminating
|
82
|
+
@terminating = true
|
81
83
|
info "sending SIGTERM to all processes"
|
82
84
|
kill_all "SIGTERM"
|
83
|
-
Timeout.timeout(5)
|
85
|
+
Timeout.timeout(5) do
|
86
|
+
while running_processes.length > 0
|
87
|
+
pid, status = Process.wait2
|
88
|
+
process = running_processes.delete(pid)
|
89
|
+
info "process terminated", process.name
|
90
|
+
end
|
91
|
+
end
|
84
92
|
rescue Timeout::Error
|
85
93
|
info "sending SIGKILL to all processes"
|
86
94
|
kill_all "SIGKILL"
|
87
95
|
end
|
88
96
|
|
97
|
+
def poll_readers
|
98
|
+
rs, ws = IO.select(readers.values, [], [], 1)
|
99
|
+
(rs || []).each do |r|
|
100
|
+
data = r.gets
|
101
|
+
next unless data
|
102
|
+
ps, message = data.split(",", 2)
|
103
|
+
color = colors[ps.split(".").first]
|
104
|
+
info message, ps, color
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
89
108
|
def watch_for_output
|
90
109
|
Thread.new do
|
91
110
|
require "win32console" if Foreman.windows?
|
92
111
|
begin
|
93
112
|
loop do
|
94
|
-
|
95
|
-
(rs || []).each do |r|
|
96
|
-
data = r.gets
|
97
|
-
next unless data
|
98
|
-
ps, message = data.split(",", 2)
|
99
|
-
color = colors[ps.split(".").first]
|
100
|
-
info message, ps, color
|
101
|
-
end
|
113
|
+
poll_readers
|
102
114
|
end
|
103
115
|
rescue Exception => ex
|
104
116
|
puts ex.message
|
@@ -112,16 +124,16 @@ private ######################################################################
|
|
112
124
|
process = running_processes.delete(pid)
|
113
125
|
info "process terminated", process.name
|
114
126
|
terminate_gracefully
|
115
|
-
kill_all
|
116
127
|
rescue Errno::ECHILD
|
117
128
|
end
|
118
129
|
|
119
130
|
def info(message, name="system", color=Term::ANSIColor.white)
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
131
|
+
output = ""
|
132
|
+
output += color
|
133
|
+
output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "
|
134
|
+
output += Term::ANSIColor.reset
|
135
|
+
output += message.chomp
|
136
|
+
puts output
|
125
137
|
end
|
126
138
|
|
127
139
|
def print(message=nil)
|
data/lib/foreman/export.rb
CHANGED
@@ -1,9 +1,30 @@
|
|
1
1
|
require "foreman"
|
2
|
+
require "foreman/helpers"
|
2
3
|
|
3
4
|
module Foreman::Export
|
5
|
+
extend Foreman::Helpers
|
6
|
+
|
4
7
|
class Exception < ::Exception; end
|
8
|
+
|
9
|
+
def self.formatter(format)
|
10
|
+
begin
|
11
|
+
require "foreman/export/#{ format.tr('-', '_') }"
|
12
|
+
classy_format = classify(format)
|
13
|
+
formatter = constantize("Foreman::Export::#{ classy_format }")
|
14
|
+
rescue NameError => ex
|
15
|
+
error "Unknown export format: #{format} (no class Foreman::Export::#{ classy_format })."
|
16
|
+
rescue LoadError => ex
|
17
|
+
error "Unknown export format: #{format} (unable to load file 'foreman/export/#{ format.tr('-', '_') }')."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.error(message)
|
22
|
+
raise Foreman::Export::Exception.new(message)
|
23
|
+
end
|
24
|
+
|
5
25
|
end
|
6
26
|
|
27
|
+
|
7
28
|
require "foreman/export/base"
|
8
29
|
require "foreman/export/inittab"
|
9
30
|
require "foreman/export/upstart"
|
@@ -24,12 +24,12 @@ class Foreman::Export::Inittab < Foreman::Export::Base
|
|
24
24
|
|
25
25
|
inittab = inittab.join("\n") + "\n"
|
26
26
|
|
27
|
-
if
|
27
|
+
if location == "-"
|
28
|
+
puts inittab
|
29
|
+
else
|
28
30
|
FileUtils.mkdir_p(log_root) rescue error "could not create #{log_root}"
|
29
31
|
FileUtils.chown(user, nil, log_root) rescue error "could not chown #{log_root} to #{user}"
|
30
|
-
write_file(
|
31
|
-
else
|
32
|
-
puts inittab
|
32
|
+
write_file(location, inittab)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/lib/foreman/helpers.rb
CHANGED
@@ -6,9 +6,8 @@ module Foreman::Helpers
|
|
6
6
|
# classify('job-name') # => 'JobName'
|
7
7
|
def classify(dashed_word)
|
8
8
|
dashed_word.split('-').each { |part| part[0] = part[0].chr.upcase }.join
|
9
|
-
end
|
9
|
+
end # Tries to find a constant with the name specified in the argument string:
|
10
10
|
|
11
|
-
# Tries to find a constant with the name specified in the argument string:
|
12
11
|
#
|
13
12
|
# constantize("Module") # => Module
|
14
13
|
# constantize("Test::Unit") # => Test::Unit
|
@@ -28,10 +27,6 @@ module Foreman::Helpers
|
|
28
27
|
def constantize(camel_cased_word)
|
29
28
|
camel_cased_word = camel_cased_word.to_s
|
30
29
|
|
31
|
-
if camel_cased_word.include?('-')
|
32
|
-
camel_cased_word = classify(camel_cased_word)
|
33
|
-
end
|
34
|
-
|
35
30
|
names = camel_cased_word.split('::')
|
36
31
|
names.shift if names.empty? || names.first.empty?
|
37
32
|
|
@@ -47,4 +42,4 @@ module Foreman::Helpers
|
|
47
42
|
end
|
48
43
|
constant
|
49
44
|
end
|
50
|
-
end
|
45
|
+
end
|
data/lib/foreman/process.rb
CHANGED
data/lib/foreman/version.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" "January 2012" "Foreman 0.
|
4
|
+
.TH "FOREMAN" "1" "January 2012" "Foreman 0.37.1" "Foreman Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
data/spec/foreman/cli_spec.rb
CHANGED
@@ -27,6 +27,15 @@ describe "Foreman::CLI", :fakefs do
|
|
27
27
|
|
28
28
|
describe "export" do
|
29
29
|
describe "options" do
|
30
|
+
it "uses .foreman" do
|
31
|
+
write_procfile
|
32
|
+
File.open(".foreman", "w") { |f| f.puts "concurrency: alpha=2" }
|
33
|
+
mock_export = mock(Foreman::Export::Upstart)
|
34
|
+
mock(Foreman::Export::Upstart).new("/upstart", is_a(Foreman::Engine), { "concurrency" => "alpha=2" }) { mock_export }
|
35
|
+
mock_export.export
|
36
|
+
foreman %{ export upstart /upstart }
|
37
|
+
end
|
38
|
+
|
30
39
|
it "respects --env" do
|
31
40
|
write_procfile
|
32
41
|
write_env("envfile")
|
@@ -49,10 +58,18 @@ describe "Foreman::CLI", :fakefs do
|
|
49
58
|
describe "with a Procfile" do
|
50
59
|
before(:each) { write_procfile }
|
51
60
|
|
52
|
-
describe "with
|
61
|
+
describe "with a formatter with a generic error" do
|
62
|
+
before do
|
63
|
+
mock(Foreman::Export).formatter("errorful") { Class.new(Foreman::Export::Base) do
|
64
|
+
def export
|
65
|
+
raise Foreman::Export::Exception.new("foo")
|
66
|
+
end
|
67
|
+
end }
|
68
|
+
end
|
69
|
+
|
53
70
|
it "prints an error" do
|
54
|
-
mock_error(subject, "
|
55
|
-
subject.export("
|
71
|
+
mock_error(subject, "foo") do
|
72
|
+
subject.export("errorful")
|
56
73
|
end
|
57
74
|
end
|
58
75
|
end
|
@@ -76,7 +93,7 @@ describe "Foreman::CLI", :fakefs do
|
|
76
93
|
before { write_procfile }
|
77
94
|
|
78
95
|
it "displays the jobs" do
|
79
|
-
mock(subject).
|
96
|
+
mock(subject).puts("valid procfile detected (alpha, bravo)")
|
80
97
|
subject.check
|
81
98
|
end
|
82
99
|
end
|
data/spec/foreman/engine_spec.rb
CHANGED
@@ -83,4 +83,23 @@ describe "Foreman::Engine", :fakefs do
|
|
83
83
|
engine.start
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
describe "utf8" do
|
88
|
+
before(:each) do
|
89
|
+
File.open("Procfile", "w") do |file|
|
90
|
+
file.puts "utf8: #{resource_path("bin/utf8")}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should spawn" do
|
95
|
+
stub(subject).watch_for_output
|
96
|
+
stub(subject).watch_for_termination
|
97
|
+
subject.start
|
98
|
+
sleep 1
|
99
|
+
mock(subject).info(/started with pid \d+/, "utf8.1", anything)
|
100
|
+
mock(subject).info("\xff\x03\n", "utf8.1", anything)
|
101
|
+
subject.send(:poll_readers)
|
102
|
+
subject.send(:poll_readers)
|
103
|
+
end
|
104
|
+
end
|
86
105
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "foreman/export/base"
|
3
|
+
|
4
|
+
describe "Foreman::Export::Base" do
|
5
|
+
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
6
|
+
let(:location) { "/tmp/init" }
|
7
|
+
let(:engine) { Foreman::Engine.new(procfile) }
|
8
|
+
let(:subject) { Foreman::Export::Base.new(location, engine) }
|
9
|
+
|
10
|
+
it "has a say method for displaying info" do
|
11
|
+
mock(subject).puts("[foreman export] foo")
|
12
|
+
subject.send(:say, "foo")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "export needs to be overridden" do
|
16
|
+
lambda { subject.export }.should raise_error("export method must be overridden")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "raises errors as a Foreman::Export::Exception" do
|
20
|
+
lambda { subject.send(:error, "foo") }.should raise_error(Foreman::Export::Exception, "foo")
|
21
|
+
end
|
22
|
+
end
|
@@ -17,7 +17,14 @@ describe Foreman::Export::Bluepill, :fakefs do
|
|
17
17
|
normalize_space(File.read("/tmp/init/app.pill")).should == normalize_space(example_export_file("bluepill/app.pill"))
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
it "cleans up if exporting into an existing dir" do
|
21
|
+
mock(FileUtils).rm("/tmp/init/app.pill")
|
22
|
+
|
23
|
+
bluepill.export
|
24
|
+
bluepill.export
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with concurrency" do
|
21
28
|
let(:options) { Hash[:concurrency => "alpha=2"] }
|
22
29
|
|
23
30
|
it "exports to the filesystem with concurrency" do
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "foreman/engine"
|
3
|
+
require "foreman/export/inittab"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
describe Foreman::Export::Inittab, :fakefs do
|
7
|
+
let(:location) { "/tmp/inittab" }
|
8
|
+
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
9
|
+
let(:location) { "/tmp/inittab" }
|
10
|
+
let(:engine) { Foreman::Engine.new(procfile) }
|
11
|
+
let(:options) { Hash.new }
|
12
|
+
let(:inittab) { Foreman::Export::Inittab.new(location, engine, options) }
|
13
|
+
|
14
|
+
before(:each) { load_export_templates_into_fakefs("inittab") }
|
15
|
+
before(:each) { stub(inittab).say }
|
16
|
+
|
17
|
+
it "exports to the filesystem" do
|
18
|
+
inittab.export
|
19
|
+
File.read("/tmp/inittab").should == example_export_file("inittab/inittab.default")
|
20
|
+
end
|
21
|
+
|
22
|
+
context "to stdout" do
|
23
|
+
let(:location) { "-" }
|
24
|
+
|
25
|
+
it "exports to stdout" do
|
26
|
+
mock(inittab).puts example_export_file("inittab/inittab.default")
|
27
|
+
inittab.export
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with concurrency" do
|
32
|
+
let(:options) { Hash[:concurrency => "alpha=2"] }
|
33
|
+
|
34
|
+
it "exports to the filesystem with concurrency" do
|
35
|
+
inittab.export
|
36
|
+
File.read("/tmp/inittab").should == example_export_file("inittab/inittab.concurrency")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -22,6 +22,17 @@ describe Foreman::Export::Upstart, :fakefs do
|
|
22
22
|
File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
|
23
23
|
end
|
24
24
|
|
25
|
+
it "cleans up if exporting into an existing dir" do
|
26
|
+
mock(FileUtils).rm("/tmp/init/app.conf")
|
27
|
+
mock(FileUtils).rm("/tmp/init/app-alpha.conf")
|
28
|
+
mock(FileUtils).rm("/tmp/init/app-alpha-1.conf")
|
29
|
+
mock(FileUtils).rm("/tmp/init/app-bravo.conf")
|
30
|
+
mock(FileUtils).rm("/tmp/init/app-bravo-1.conf")
|
31
|
+
|
32
|
+
upstart.export
|
33
|
+
upstart.export
|
34
|
+
end
|
35
|
+
|
25
36
|
context "with concurrency" do
|
26
37
|
let(:options) { Hash[:concurrency => "alpha=2"] }
|
27
38
|
|
data/spec/foreman/export_spec.rb
CHANGED
@@ -1,2 +1,24 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "foreman/export"
|
3
|
+
|
4
|
+
describe "Foreman::Export" do
|
5
|
+
subject { Foreman::Export }
|
6
|
+
|
7
|
+
describe "with a formatter that doesn't declare the appropriate class" do
|
8
|
+
it "prints an error" do
|
9
|
+
mock(subject).require("foreman/export/invalidformatter")
|
10
|
+
mock_export_error("Unknown export format: invalidformatter (no class Foreman::Export::Invalidformatter).") do
|
11
|
+
subject.formatter("invalidformatter")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "with an invalid formatter" do
|
17
|
+
|
18
|
+
it "prints an error" do
|
19
|
+
mock_export_error("Unknown export format: invalidformatter (unable to load file 'foreman/export/invalidformatter').") do
|
20
|
+
subject.formatter("invalidformatter")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "foreman/helpers"
|
3
|
+
|
4
|
+
describe "Foreman::Helpers" do
|
5
|
+
before do
|
6
|
+
module Foo
|
7
|
+
class Bar; end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Object.send(:remove_const, :Foo)
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { o = Object.new; o.extend(Foreman::Helpers); o }
|
16
|
+
|
17
|
+
it "should classify words" do
|
18
|
+
subject.classify("foo").should == "Foo"
|
19
|
+
subject.classify("foo-bar").should == "FooBar"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should constantize words" do
|
23
|
+
subject.constantize("Object").should == Object
|
24
|
+
subject.constantize("Foo::Bar").should == Foo::Bar
|
25
|
+
end
|
26
|
+
end
|
@@ -36,6 +36,7 @@ describe Foreman::Process do
|
|
36
36
|
def run_file(executable, code)
|
37
37
|
file = File.open("#{basedir}/script", 'w') {|it| it << code }
|
38
38
|
run "#{executable} #{file.path}"
|
39
|
+
sleep 1
|
39
40
|
end
|
40
41
|
|
41
42
|
context 'options' do
|
@@ -98,7 +99,6 @@ describe Foreman::Process do
|
|
98
99
|
trap "TERM", "IGNORE"
|
99
100
|
loop { sleep 1 }
|
100
101
|
CODE
|
101
|
-
sleep 1 # wait for ruby to start
|
102
102
|
subject.should be_alive
|
103
103
|
subject.kill 'TERM'
|
104
104
|
subject.should be_alive
|
data/spec/foreman_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
require "rubygems"
|
2
|
+
|
3
|
+
require "simplecov"
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter "/spec/"
|
6
|
+
end
|
7
|
+
|
2
8
|
require "rspec"
|
3
9
|
require "fakefs/safe"
|
4
10
|
require "fakefs/spec_helpers"
|
5
11
|
|
6
12
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
7
13
|
|
14
|
+
def mock_export_error(message)
|
15
|
+
lambda { yield }.should raise_error(Foreman::Export::Exception, message)
|
16
|
+
end
|
17
|
+
|
8
18
|
def mock_error(subject, message)
|
9
19
|
mock_exit do
|
10
20
|
mock(subject).puts("ERROR: #{message}")
|
@@ -37,9 +47,11 @@ def write_procfile(procfile="Procfile", alpha_env="")
|
|
37
47
|
File.expand_path(procfile)
|
38
48
|
end
|
39
49
|
|
40
|
-
def write_env(env=".env")
|
50
|
+
def write_env(env=".env", options={"FOO"=>"bar"})
|
41
51
|
File.open(env, "w") do |file|
|
42
|
-
|
52
|
+
options.each do |key, val|
|
53
|
+
file.puts "#{key}=#{val}"
|
54
|
+
end
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
@@ -56,9 +68,13 @@ def load_export_templates_into_fakefs(type)
|
|
56
68
|
end
|
57
69
|
end
|
58
70
|
|
71
|
+
def resource_path(filename)
|
72
|
+
File.expand_path("../resources/#{filename}", __FILE__)
|
73
|
+
end
|
74
|
+
|
59
75
|
def example_export_file(filename)
|
60
76
|
FakeFS.deactivate!
|
61
|
-
data = File.read(File.expand_path("
|
77
|
+
data = File.read(File.expand_path(resource_path("export/#{filename}"), __FILE__))
|
62
78
|
FakeFS.activate!
|
63
79
|
data
|
64
80
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.37.
|
5
|
-
prerelease:
|
4
|
+
version: 0.37.1
|
5
|
+
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- David Dollar
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-29 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: term-ansicolor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70189995772300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70189995772300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &70189995754980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.13.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70189995754980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: posix-spawn
|
38
|
-
requirement: &
|
38
|
+
requirement: &70189995753460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.3.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70189995753460
|
47
47
|
description: Process manager for applications with multiple components
|
48
48
|
email: ddollar@gmail.com
|
49
49
|
executables:
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- data/example/Procfile
|
59
59
|
- data/example/Procfile.without_colon
|
60
60
|
- data/example/ticker
|
61
|
+
- data/example/utf8
|
61
62
|
- data/export/bluepill/master.pill.erb
|
62
63
|
- data/export/runit/log_run.erb
|
63
64
|
- data/export/runit/run.erb
|
@@ -83,15 +84,21 @@ files:
|
|
83
84
|
- README.md
|
84
85
|
- spec/foreman/cli_spec.rb
|
85
86
|
- spec/foreman/engine_spec.rb
|
87
|
+
- spec/foreman/export/base_spec.rb
|
86
88
|
- spec/foreman/export/bluepill_spec.rb
|
89
|
+
- spec/foreman/export/inittab_spec.rb
|
87
90
|
- spec/foreman/export/runit_spec.rb
|
88
91
|
- spec/foreman/export/upstart_spec.rb
|
89
92
|
- spec/foreman/export_spec.rb
|
93
|
+
- spec/foreman/helpers_spec.rb
|
90
94
|
- spec/foreman/process_spec.rb
|
91
95
|
- spec/foreman_spec.rb
|
92
96
|
- spec/helper_spec.rb
|
97
|
+
- spec/resources/bin/utf8
|
93
98
|
- spec/resources/export/bluepill/app-concurrency.pill
|
94
99
|
- spec/resources/export/bluepill/app.pill
|
100
|
+
- spec/resources/export/inittab/inittab.concurrency
|
101
|
+
- spec/resources/export/inittab/inittab.default
|
95
102
|
- spec/resources/export/runit/app-alpha-1-log-run
|
96
103
|
- spec/resources/export/runit/app-alpha-1-run
|
97
104
|
- spec/resources/export/runit/app-alpha-2-log-run
|
@@ -121,12 +128,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
129
|
none: false
|
123
130
|
requirements:
|
124
|
-
- - ! '
|
131
|
+
- - ! '>='
|
125
132
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
133
|
+
version: '0'
|
127
134
|
requirements: []
|
128
135
|
rubyforge_project:
|
129
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.10
|
130
137
|
signing_key:
|
131
138
|
specification_version: 3
|
132
139
|
summary: Process manager for applications with multiple components
|