foreman 0.40.0-mingw32 → 0.41.0-mingw32

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.
@@ -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
+ %>
@@ -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
@@ -1,10 +1,10 @@
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
 
@@ -15,11 +15,10 @@ class Foreman::Engine
15
15
  attr_reader :directory
16
16
  attr_reader :options
17
17
 
18
- extend Term::ANSIColor
18
+ COLORS = %w( cyan yellow green magenta red blue intense_cyan intense_yellow
19
+ intense_green intense_magenta intense_red, intense_blue )
19
20
 
20
- COLORS = [ cyan, yellow, green, magenta, red, blue,
21
- intense_cyan, intense_yellow, intense_green, intense_magenta,
22
- intense_red, intense_blue ]
21
+ Foreman::Color.enable($stdout)
23
22
 
24
23
  def initialize(procfile, options={})
25
24
  @procfile = Foreman::Procfile.new(procfile)
@@ -128,11 +127,11 @@ private ######################################################################
128
127
  rescue Errno::ECHILD
129
128
  end
130
129
 
131
- def info(message, name="system", color=Term::ANSIColor.white)
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 += Term::ANSIColor.reset
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.each do |entry|
186
- colors[entry.name] = next_color
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,13 +190,6 @@ private ######################################################################
191
190
  readers.invert[reader]
192
191
  end
193
192
 
194
- def next_color
195
- @current_color ||= -1
196
- @current_color += 1
197
- @current_color = 0 if COLORS.length < @current_color
198
- COLORS[@current_color]
199
- end
200
-
201
193
  def read_environment_files(filenames)
202
194
  environment = {}
203
195
 
@@ -30,3 +30,5 @@ require "foreman/export/inittab"
30
30
  require "foreman/export/upstart"
31
31
  require "foreman/export/bluepill"
32
32
  require "foreman/export/runit"
33
+ require "foreman/export/supervisord"
34
+
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.40.0"
3
+ VERSION = "0.41.0"
4
4
 
5
5
  end
@@ -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
@@ -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
@@ -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.40.0
4
+ version: 0.41.0
5
5
  prerelease:
6
6
  platform: mingw32
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000 Z
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: term-ansicolor
16
- requirement: &70287555411520 !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: *70287555411520
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: thor
27
- requirement: &70287555410140 !ruby/object:Gem::Requirement
16
+ requirement: &70292585295960 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,10 +21,10 @@ dependencies:
32
21
  version: 0.13.6
33
22
  type: :runtime
34
23
  prerelease: false
35
- version_requirements: *70287555410140
24
+ version_requirements: *70292585295960
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: win32console
38
- requirement: &70287555408580 !ruby/object:Gem::Requirement
27
+ requirement: &70292585295160 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ~>
@@ -43,7 +32,7 @@ dependencies:
43
32
  version: 1.3.0
44
33
  type: :runtime
45
34
  prerelease: false
46
- version_requirements: *70287555408580
35
+ version_requirements: *70292585295160
47
36
  description: Process manager for applications with multiple components
48
37
  email: ddollar@gmail.com
49
38
  executables:
@@ -62,16 +51,19 @@ files:
62
51
  - data/export/bluepill/master.pill.erb
63
52
  - data/export/runit/log_run.erb
64
53
  - data/export/runit/run.erb
54
+ - data/export/supervisord/app.conf.erb
65
55
  - data/export/upstart/master.conf.erb
66
56
  - data/export/upstart/process.conf.erb
67
57
  - data/export/upstart/process_master.conf.erb
68
58
  - lib/foreman/cli.rb
59
+ - lib/foreman/color.rb
69
60
  - lib/foreman/distribution.rb
70
61
  - lib/foreman/engine.rb
71
62
  - lib/foreman/export/base.rb
72
63
  - lib/foreman/export/bluepill.rb
73
64
  - lib/foreman/export/inittab.rb
74
65
  - lib/foreman/export/runit.rb
66
+ - lib/foreman/export/supervisord.rb
75
67
  - lib/foreman/export/upstart.rb
76
68
  - lib/foreman/export.rb
77
69
  - lib/foreman/helpers.rb
@@ -83,11 +75,13 @@ files:
83
75
  - lib/foreman.rb
84
76
  - README.md
85
77
  - spec/foreman/cli_spec.rb
78
+ - spec/foreman/color_spec.rb
86
79
  - spec/foreman/engine_spec.rb
87
80
  - spec/foreman/export/base_spec.rb
88
81
  - spec/foreman/export/bluepill_spec.rb
89
82
  - spec/foreman/export/inittab_spec.rb
90
83
  - spec/foreman/export/runit_spec.rb
84
+ - spec/foreman/export/supervisord_spec.rb
91
85
  - spec/foreman/export/upstart_spec.rb
92
86
  - spec/foreman/export_spec.rb
93
87
  - spec/foreman/helpers_spec.rb
@@ -105,6 +99,8 @@ files:
105
99
  - spec/resources/export/runit/app-alpha-2-run
106
100
  - spec/resources/export/runit/app-bravo-1-log-run
107
101
  - spec/resources/export/runit/app-bravo-1-run
102
+ - spec/resources/export/supervisord/app-alpha-2.conf
103
+ - spec/resources/export/supervisord/app.conf
108
104
  - spec/resources/export/upstart/app-alpha-1.conf
109
105
  - spec/resources/export/upstart/app-alpha-2.conf
110
106
  - spec/resources/export/upstart/app-alpha.conf