foreman 0.37.0-java → 0.38.0-java
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 +2 -1
- data/bin/runner +1 -1
- data/data/example/Procfile +1 -0
- data/data/example/utf8 +11 -0
- data/lib/foreman/cli.rb +3 -2
- data/lib/foreman/engine.rb +15 -10
- data/lib/foreman/version.rb +1 -1
- data/man/foreman.1 +1 -1
- data/spec/foreman/cli_spec.rb +11 -0
- data/spec/foreman/engine_spec.rb +26 -0
- data/spec/foreman/process_spec.rb +1 -1
- data/spec/resources/bin/utf8 +2 -0
- data/spec/spec_helper.rb +5 -1
- metadata +11 -9
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/bin/runner
CHANGED
data/data/example/Procfile
CHANGED
data/data/example/utf8
ADDED
data/lib/foreman/cli.rb
CHANGED
|
@@ -10,7 +10,7 @@ class Foreman::CLI < Thor
|
|
|
10
10
|
|
|
11
11
|
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile"
|
|
12
12
|
|
|
13
|
-
desc "start", "Start the application"
|
|
13
|
+
desc "start [PROCESS]", "Start the application (or a specific PROCESS)"
|
|
14
14
|
|
|
15
15
|
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile"
|
|
16
16
|
class_option :app_root, :type => :string, :aliases => "-d", :desc => "Default: Procfile directory"
|
|
@@ -27,8 +27,9 @@ class Foreman::CLI < Thor
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def start
|
|
30
|
+
def start(process=nil)
|
|
31
31
|
check_procfile!
|
|
32
|
+
engine.options[:concurrency] = "#{process}=1" if process
|
|
32
33
|
engine.start
|
|
33
34
|
end
|
|
34
35
|
|
data/lib/foreman/engine.rb
CHANGED
|
@@ -23,7 +23,7 @@ class Foreman::Engine
|
|
|
23
23
|
def initialize(procfile, options={})
|
|
24
24
|
@procfile = Foreman::Procfile.new(procfile)
|
|
25
25
|
@directory = options[:app_root] || File.expand_path(File.dirname(procfile))
|
|
26
|
-
@options = options
|
|
26
|
+
@options = options.dup
|
|
27
27
|
@environment = read_environment_files(options[:env])
|
|
28
28
|
@output_mutex = Mutex.new
|
|
29
29
|
end
|
|
@@ -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
|
|
@@ -94,19 +94,24 @@ private ######################################################################
|
|
|
94
94
|
kill_all "SIGKILL"
|
|
95
95
|
end
|
|
96
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
|
+
data.force_encoding("BINARY") if data.respond_to?(:force_encoding)
|
|
103
|
+
ps, message = data.split(",", 2)
|
|
104
|
+
color = colors[ps.split(".").first]
|
|
105
|
+
info message, ps, color
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
97
109
|
def watch_for_output
|
|
98
110
|
Thread.new do
|
|
99
111
|
require "win32console" if Foreman.windows?
|
|
100
112
|
begin
|
|
101
113
|
loop do
|
|
102
|
-
|
|
103
|
-
(rs || []).each do |r|
|
|
104
|
-
data = r.gets
|
|
105
|
-
next unless data
|
|
106
|
-
ps, message = data.split(",", 2)
|
|
107
|
-
color = colors[ps.split(".").first]
|
|
108
|
-
info message, ps, color
|
|
109
|
-
end
|
|
114
|
+
poll_readers
|
|
110
115
|
end
|
|
111
116
|
rescue Exception => ex
|
|
112
117
|
puts ex.message
|
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.2" "Foreman Manual"
|
|
5
5
|
.
|
|
6
6
|
.SH "NAME"
|
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
data/spec/foreman/cli_spec.rb
CHANGED
|
@@ -3,6 +3,8 @@ require "foreman/cli"
|
|
|
3
3
|
|
|
4
4
|
describe "Foreman::CLI", :fakefs do
|
|
5
5
|
subject { Foreman::CLI.new }
|
|
6
|
+
let(:engine) { subject.send(:engine) }
|
|
7
|
+
let(:entries) { engine.procfile.entries.inject({}) { |h,e| h.update(e.name => e) } }
|
|
6
8
|
|
|
7
9
|
describe "start" do
|
|
8
10
|
describe "with a non-existent Procfile" do
|
|
@@ -22,6 +24,15 @@ describe "Foreman::CLI", :fakefs do
|
|
|
22
24
|
mock.instance_of(Foreman::Engine).start
|
|
23
25
|
subject.start
|
|
24
26
|
end
|
|
27
|
+
|
|
28
|
+
it "can run a single process" do
|
|
29
|
+
dont_allow(subject).error
|
|
30
|
+
stub(engine).watch_for_output
|
|
31
|
+
stub(engine).watch_for_termination
|
|
32
|
+
mock(entries["alpha"]).spawn(1, is_a(IO), engine.directory, {}, 5000) { [] }
|
|
33
|
+
mock(entries["bravo"]).spawn(0, is_a(IO), engine.directory, {}, 5100) { [] }
|
|
34
|
+
subject.start("alpha")
|
|
35
|
+
end
|
|
25
36
|
end
|
|
26
37
|
end
|
|
27
38
|
|
data/spec/foreman/engine_spec.rb
CHANGED
|
@@ -4,6 +4,13 @@ require "foreman/engine"
|
|
|
4
4
|
describe "Foreman::Engine", :fakefs do
|
|
5
5
|
subject { Foreman::Engine.new("Procfile", {}) }
|
|
6
6
|
|
|
7
|
+
before do
|
|
8
|
+
any_instance_of(Foreman::Engine) do |engine|
|
|
9
|
+
stub(engine).proctitle
|
|
10
|
+
stub(engine).termtitle
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
7
14
|
describe "initialize" do
|
|
8
15
|
describe "without an existing Procfile" do
|
|
9
16
|
it "raises an error" do
|
|
@@ -83,4 +90,23 @@ describe "Foreman::Engine", :fakefs do
|
|
|
83
90
|
engine.start
|
|
84
91
|
end
|
|
85
92
|
end
|
|
93
|
+
|
|
94
|
+
describe "utf8" do
|
|
95
|
+
before(:each) do
|
|
96
|
+
File.open("Procfile", "w") do |file|
|
|
97
|
+
file.puts "utf8: #{resource_path("bin/utf8")}"
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should spawn" do
|
|
102
|
+
stub(subject).watch_for_output
|
|
103
|
+
stub(subject).watch_for_termination
|
|
104
|
+
subject.start
|
|
105
|
+
Process.waitall
|
|
106
|
+
mock(subject).info(/started with pid \d+/, "utf8.1", anything)
|
|
107
|
+
mock(subject).info("\xff\x03\n", "utf8.1", anything)
|
|
108
|
+
subject.send(:poll_readers)
|
|
109
|
+
subject.send(:poll_readers)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
86
112
|
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/spec_helper.rb
CHANGED
|
@@ -68,9 +68,13 @@ def load_export_templates_into_fakefs(type)
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
def resource_path(filename)
|
|
72
|
+
File.expand_path("../resources/#{filename}", __FILE__)
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
def example_export_file(filename)
|
|
72
76
|
FakeFS.deactivate!
|
|
73
|
-
data = File.read(File.expand_path("
|
|
77
|
+
data = File.read(File.expand_path(resource_path("export/#{filename}"), __FILE__))
|
|
74
78
|
FakeFS.activate!
|
|
75
79
|
data
|
|
76
80
|
end
|
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.38.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: java
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-02-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: term-ansicolor
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70107721010340 !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: *70107721010340
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: thor
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &70107721009580 !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: *70107721009580
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: posix-spawn
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &70107721007300 !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: *70107721007300
|
|
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
|
|
@@ -93,6 +94,7 @@ files:
|
|
|
93
94
|
- spec/foreman/process_spec.rb
|
|
94
95
|
- spec/foreman_spec.rb
|
|
95
96
|
- spec/helper_spec.rb
|
|
97
|
+
- spec/resources/bin/utf8
|
|
96
98
|
- spec/resources/export/bluepill/app-concurrency.pill
|
|
97
99
|
- spec/resources/export/bluepill/app.pill
|
|
98
100
|
- spec/resources/export/inittab/inittab.concurrency
|
|
@@ -131,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
131
133
|
version: '0'
|
|
132
134
|
requirements: []
|
|
133
135
|
rubyforge_project:
|
|
134
|
-
rubygems_version: 1.8.
|
|
136
|
+
rubygems_version: 1.8.11
|
|
135
137
|
signing_key:
|
|
136
138
|
specification_version: 3
|
|
137
139
|
summary: Process manager for applications with multiple components
|