foreman 0.37.0 → 0.38.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 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
@@ -18,7 +18,7 @@ usage() {
18
18
 
19
19
  while getopts ":hd:" OPT; do
20
20
  case $OPT in
21
- d) cd $OPTARG ;;
21
+ d) cd "$OPTARG" ;;
22
22
  h) usage ;;
23
23
  \?) error "invalid option: -$OPTARG" ;;
24
24
  :) error "option -$OPTARG requires an argument" ;;
@@ -1,2 +1,3 @@
1
1
  ticker: ruby ./ticker $PORT
2
2
  error: ruby ./error
3
+ utf8: ruby ./utf8
data/data/example/utf8 ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: BINARY
3
+
4
+ $stdout.sync = true
5
+
6
+ while true
7
+ puts "\u65e5\u672c\u8a9e\u6587\u5b57\u5217"
8
+ puts "\u0915\u0932\u094d\u0907\u0928\u0643\u0637\u0628\u041a\u0430\u043b\u0438\u043d\u0430"
9
+ puts "\xff\x03"
10
+ sleep 1
11
+ end
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
 
@@ -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
- rs, ws = IO.select(readers.values, [], [], 1)
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
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.37.0"
3
+ VERSION = "0.38.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" "January 2012" "Foreman 0.33.1" "Foreman Manual"
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
@@ -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
 
@@ -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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ puts "\xff\x03"
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("../resources/export/#{filename}", __FILE__))
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.37.0
4
+ version: 0.38.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-01-29 00:00:00.000000000 Z
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: &70149919501700 !ruby/object:Gem::Requirement
16
+ requirement: &70157364076040 !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: *70149919501700
24
+ version_requirements: *70157364076040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70149919500700 !ruby/object:Gem::Requirement
27
+ requirement: &70157364075220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.13.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70149919500700
35
+ version_requirements: *70157364075220
36
36
  description: Process manager for applications with multiple components
37
37
  email: ddollar@gmail.com
38
38
  executables:
@@ -47,6 +47,7 @@ files:
47
47
  - data/example/Procfile
48
48
  - data/example/Procfile.without_colon
49
49
  - data/example/ticker
50
+ - data/example/utf8
50
51
  - data/export/bluepill/master.pill.erb
51
52
  - data/export/runit/log_run.erb
52
53
  - data/export/runit/run.erb
@@ -82,6 +83,7 @@ files:
82
83
  - spec/foreman/process_spec.rb
83
84
  - spec/foreman_spec.rb
84
85
  - spec/helper_spec.rb
86
+ - spec/resources/bin/utf8
85
87
  - spec/resources/export/bluepill/app-concurrency.pill
86
88
  - spec/resources/export/bluepill/app.pill
87
89
  - spec/resources/export/inittab/inittab.concurrency
@@ -112,15 +114,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
114
  - - ! '>='
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
117
+ segments:
118
+ - 0
119
+ hash: -2171581925377059315
115
120
  required_rubygems_version: !ruby/object:Gem::Requirement
116
121
  none: false
117
122
  requirements:
118
123
  - - ! '>='
119
124
  - !ruby/object:Gem::Version
120
125
  version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -2171581925377059315
121
129
  requirements: []
122
130
  rubyforge_project:
123
- rubygems_version: 1.8.15
131
+ rubygems_version: 1.8.11
124
132
  signing_key:
125
133
  specification_version: 3
126
134
  summary: Process manager for applications with multiple components