foreman 0.60.2 → 0.61.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.
@@ -8,8 +8,8 @@ module Foreman
8
8
  File.expand_path("../../bin/foreman-runner", __FILE__)
9
9
  end
10
10
 
11
- def self.jruby?
12
- defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
11
+ def self.jruby_18?
12
+ defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java" and ruby_18?
13
13
  end
14
14
 
15
15
  def self.ruby_18?
@@ -12,7 +12,7 @@ if defined?(Capistrano)
12
12
  set :foreman_procfile, "Procfile"
13
13
  set :foreman_app, application
14
14
  set :foreman_user, user
15
- set :foreman_log, "#{shared_path}/log"
15
+ set :foreman_log, 'shared_path/log'
16
16
  set :foreman_concurrency, false
17
17
  DESC
18
18
  task :export, :roles => :app do
@@ -23,6 +23,7 @@ class Foreman::CLI < Thor
23
23
  method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
24
24
  method_option :formation, :type => :string, :aliases => "-m", :banner => '"alpha=5,bar=3"'
25
25
  method_option :port, :type => :numeric, :aliases => "-p"
26
+ method_option :timeout, :type => :numeric, :aliases => "-t", :desc => "Specify the amount of time (in seconds) processes have to shudown gracefully before receiving a SIGKILL, defaults to 5."
26
27
 
27
28
  class << self
28
29
  # Hackery. Take the run method away from Thor so that we can redefine it.
@@ -25,6 +25,7 @@ class Foreman::Engine
25
25
  @options = options.dup
26
26
 
27
27
  @options[:formation] ||= (options[:concurrency] || "all=1")
28
+ @options[:timeout] ||= 5
28
29
 
29
30
  @env = {}
30
31
  @mutex = Mutex.new
@@ -37,6 +38,9 @@ class Foreman::Engine
37
38
  # Start the processes registered to this +Engine+
38
39
  #
39
40
  def start
41
+ # Make sure foreman is the process group leader.
42
+ Process.setpgrp unless Foreman.windows?
43
+
40
44
  trap("TERM") { puts "SIGTERM received"; terminate_gracefully }
41
45
  trap("INT") { puts "SIGINT received"; terminate_gracefully }
42
46
  trap("HUP") { puts "SIGHUP received"; terminate_gracefully } if ::Signal.list.keys.include? 'HUP'
@@ -109,7 +113,7 @@ class Foreman::Engine
109
113
  end
110
114
  else
111
115
  begin
112
- Process.kill "-#{signal}", Process.pid
116
+ Process.kill "-#{signal}", Process.getpgrp
113
117
  rescue Errno::ESRCH, Errno::EPERM
114
118
  end
115
119
  end
@@ -275,8 +279,12 @@ private
275
279
  loop do
276
280
  io = IO.select(@readers.values, nil, nil, 30)
277
281
  (io.nil? ? [] : io.first).each do |reader|
278
- data = reader.gets
279
- output_with_mutex name_for(@readers.invert[reader]), data
282
+ if reader.eof?
283
+ @readers.delete_if { |key, value| value == reader }
284
+ else
285
+ data = reader.gets
286
+ output_with_mutex name_for(@readers.invert[reader]), data
287
+ end
280
288
  end
281
289
  end
282
290
  rescue Exception => ex
@@ -305,7 +313,7 @@ private
305
313
  system "sending SIGTERM to all processes"
306
314
  killall "SIGTERM"
307
315
  end
308
- Timeout.timeout(5) do
316
+ Timeout.timeout(options[:timeout]) do
309
317
  watch_for_termination while @running.length > 0
310
318
  end
311
319
  rescue Timeout::Error
@@ -44,8 +44,8 @@ class Foreman::Engine::CLI < Foreman::Engine
44
44
 
45
45
  end
46
46
 
47
- FOREMAN_COLORS = %w( cyan yellow green magenta red blue intense_cyan intense_yellow
48
- intense_green intense_magenta intense_red, intense_blue )
47
+ FOREMAN_COLORS = %w( cyan yellow green magenta red blue bright_cyan bright_yellow
48
+ bright_green bright_magenta bright_red bright_blue )
49
49
 
50
50
  def startup
51
51
  @colors = map_colors
@@ -54,7 +54,7 @@ class Foreman::Engine::CLI < Foreman::Engine
54
54
  end
55
55
 
56
56
  def output(name, data)
57
- data.to_s.chomp.split("\n").each do |message|
57
+ data.to_s.lines.map(&:chomp).each do |message|
58
58
  output = ""
59
59
  output += $stdout.color(@colors[name.split(".").first].to_sym)
60
60
  output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "
@@ -89,7 +89,7 @@ private
89
89
  @names.values.each_with_index do |name, index|
90
90
  colors[name] = FOREMAN_COLORS[index % FOREMAN_COLORS.length]
91
91
  end
92
- colors["system"] = "intense_white"
92
+ colors["system"] = "bright_white"
93
93
  colors
94
94
  end
95
95
 
@@ -5,7 +5,7 @@ class Foreman::Env
5
5
  attr_reader :entries
6
6
 
7
7
  def initialize(filename)
8
- @entries = File.read(filename).split("\n").inject({}) do |ax, line|
8
+ @entries = File.read(filename).gsub("\r\n","\n").split("\n").inject({}) do |ax, line|
9
9
  if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
10
10
  key = $1
11
11
  case val = $2
@@ -91,7 +91,7 @@ private ######################################################################
91
91
  end
92
92
 
93
93
  def shell_quote(value)
94
- '"' + Shellwords.escape(value) + '"'
94
+ Shellwords.escape(value)
95
95
  end
96
96
 
97
97
  # deprecated
@@ -1,5 +1,4 @@
1
1
  require "foreman"
2
- require "rubygems"
3
2
 
4
3
  class Foreman::Process
5
4
 
@@ -53,7 +52,7 @@ class Foreman::Process
53
52
  Dir.chdir(cwd) do
54
53
  Process.spawn env, expanded_command(env), :out => output, :err => output
55
54
  end
56
- elsif Foreman.jruby?
55
+ elsif Foreman.jruby_18?
57
56
  require "posix/spawn"
58
57
  wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
59
58
  POSIX::Spawn.spawn env, wrapped_command, :out => output, :err => output
@@ -82,7 +82,7 @@ class Foreman::Procfile
82
82
  private
83
83
 
84
84
  def parse(filename)
85
- File.read(filename).split("\n").map do |line|
85
+ File.read(filename).gsub("\r\n","\n").split("\n").map do |line|
86
86
  if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
87
87
  [$1, $2]
88
88
  end
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.60.2"
3
+ VERSION = "0.61.0"
4
4
 
5
5
  end
@@ -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" "August 2012" "Foreman 0.60.1" "Foreman Manual"
4
+ .TH "FOREMAN" "1" "January 2013" "Foreman 0.61.0" "Foreman Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBforeman\fR \- manage Procfile\-based applications
@@ -90,7 +90,7 @@ Specify the user the application should be run as\. Defaults to the app name
90
90
  These options control all modes of foreman\'s operation\.
91
91
  .
92
92
  .TP
93
- \fB\-d\fR, \fB\-\-directory\fR
93
+ \fB\-d\fR, \fB\-\-root\fR
94
94
  Specify an alternate application root\. This defaults to the directory containing the Procfile\.
95
95
  .
96
96
  .TP
@@ -38,7 +38,7 @@ describe Foreman::Export::Upstart, :fakefs do
38
38
  engine.env['KEY'] = 'd"\|d'
39
39
  upstart.export
40
40
  "foobarfoo".should include "bar"
41
- File.read("/tmp/init/app-alpha-1.conf").should =~ /KEY="d\\"\\\\\\\|d/
41
+ File.read("/tmp/init/app-alpha-1.conf").should =~ /KEY=d\\"\\\\\\\|d/
42
42
  end
43
43
 
44
44
  context "with a formation" do
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log
8
8
  stderr_logfile=/var/log/app/alpha-1.error.log
9
9
  user=app
10
10
  directory=/tmp/app
11
- environment=PORT="5000"
11
+ environment=PORT=5000
12
12
  [program:app-bravo-1]
13
13
  command=./bravo
14
14
  autostart=true
@@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/bravo-1.log
18
18
  stderr_logfile=/var/log/app/bravo-1.error.log
19
19
  user=app
20
20
  directory=/tmp/app
21
- environment=PORT="5100"
21
+ environment=PORT=5100
22
22
 
23
23
  [group:app]
24
24
  programs=app-alpha-1,app-bravo-1
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log
8
8
  stderr_logfile=/var/log/app/alpha-1.error.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,7 +18,7 @@ stdout_logfile=/var/log/app/alpha-2.log
18
18
  stderr_logfile=/var/log/app/alpha-2.error.log
19
19
  user=app
20
20
  directory=/tmp/app
21
- environment=PORT="5001"
21
+ environment=PORT=5001
22
22
 
23
23
  [group:app]
24
24
  programs=app-alpha-1,app-alpha-2
@@ -1,5 +1,3 @@
1
- require "rubygems"
2
-
3
1
  require "simplecov"
4
2
  SimpleCov.start do
5
3
  add_filter "/spec/"
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.60.2
4
+ version: 0.61.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-10-08 00:00:00.000000000 Z
12
+ date: 2013-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70307655459020 !ruby/object:Gem::Requirement
16
+ requirement: &70365748678500 !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: *70307655459020
24
+ version_requirements: *70365748678500
25
25
  description: Process manager for applications with multiple components
26
26
  email: ddollar@gmail.com
27
27
  executables:
@@ -112,7 +112,8 @@ files:
112
112
  - spec/spec_helper.rb
113
113
  - man/foreman.1
114
114
  homepage: http://github.com/ddollar/foreman
115
- licenses: []
115
+ licenses:
116
+ - MIT
116
117
  post_install_message:
117
118
  rdoc_options: []
118
119
  require_paths:
@@ -123,12 +124,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
124
  - - ! '>='
124
125
  - !ruby/object:Gem::Version
125
126
  version: '0'
127
+ segments:
128
+ - 0
129
+ hash: -555731677755334112
126
130
  required_rubygems_version: !ruby/object:Gem::Requirement
127
131
  none: false
128
132
  requirements:
129
133
  - - ! '>='
130
134
  - !ruby/object:Gem::Version
131
135
  version: '0'
136
+ segments:
137
+ - 0
138
+ hash: -555731677755334112
132
139
  requirements: []
133
140
  rubyforge_project:
134
141
  rubygems_version: 1.8.11
@@ -136,3 +143,4 @@ signing_key:
136
143
  specification_version: 3
137
144
  summary: Process manager for applications with multiple components
138
145
  test_files: []
146
+ has_rdoc: