Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5689d75a87 | ||
|
|
1325b6750e | ||
|
|
638005403f | ||
|
|
55f274532f | ||
|
|
66f76c2036 | ||
|
|
865cabb525 | ||
|
|
7c3c4bc58f | ||
|
|
2dbe8c733b | ||
|
|
84352b82cc | ||
|
|
383c1f87af | ||
|
|
ce3003b026 | ||
|
|
e06f4b2f9e | ||
|
|
b721fd894e | ||
|
|
b8ea6fd4b3 | ||
|
|
dbda63263b | ||
|
|
93cdc31be0 | ||
|
|
4dfbe46690 | ||
|
|
0033f9caeb | ||
|
|
74839800a9 | ||
|
|
b75337e21e | ||
|
|
d94f941189 | ||
|
|
0b34f067cb | ||
|
|
dbe51832b0 | ||
|
|
3a2a53be95 | ||
|
|
b2bf95479e | ||
|
|
48f764e347 | ||
|
|
de62d0655e | ||
|
|
38aecff886 | ||
|
|
e4a3215257 | ||
|
|
c705b5fbef | ||
|
|
69216b4c5e | ||
|
|
5d2930745a | ||
|
|
8fc3d1ef24 | ||
|
|
d33e4fb0ed | ||
|
|
39b48b566f | ||
|
|
2f982ff9c7 | ||
|
|
1217ef1b56 | ||
|
|
c9943d70ec | ||
|
|
08dca57eb4 | ||
|
|
bb3377407a | ||
|
|
084b9493d1 | ||
|
|
279a251c78 | ||
|
|
a49ef286e8 | ||
|
|
0b3da59947 | ||
|
|
1f725dd68a | ||
|
|
2272f76479 | ||
|
|
cf4762071c | ||
|
|
1127551369 | ||
|
|
8cb58b8517 | ||
|
|
d03e931b67 | ||
|
|
9ba2b32b36 |
@@ -1,3 +1,26 @@
|
|||||||
|
## 0.43.0 (2012-04-20)
|
||||||
|
|
||||||
|
* wrap supervisord env vars in quotes [Raphael Randschau]
|
||||||
|
|
||||||
|
## 0.42.0 (2012-04-18)
|
||||||
|
|
||||||
|
* Move read_environment to a public class method. [Phil Hagelberg]
|
||||||
|
* Drop parka dependency [Phil Hagelberg]
|
||||||
|
* add group support for supervisord [Raphael Randschau]
|
||||||
|
* fix enviroment export [Raphael Randschau]
|
||||||
|
|
||||||
|
## 0.41.0 (2012-03-16)
|
||||||
|
|
||||||
|
* replace term-ansicolor with built-in colorization [David Dollar]
|
||||||
|
* supervisord export template [Raphael Randschau]
|
||||||
|
|
||||||
|
## 0.40.0 (2012-02-24)
|
||||||
|
|
||||||
|
* support various quoting styles in .env [David Dollar]
|
||||||
|
* remove load_env! as it's made unnecessary by foreman run [David Dollar]
|
||||||
|
* Provide a useful error if `foreman check` fails to find a Procfile [R. Tyler Croy]
|
||||||
|
* update docs [David Dollar]
|
||||||
|
|
||||||
## 0.39.0 (2012-02-07)
|
## 0.39.0 (2012-02-07)
|
||||||
|
|
||||||
* rename bin/runner to bin/foreman-runner [David Dollar]
|
* rename bin/runner to bin/foreman-runner [David Dollar]
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ end
|
|||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'aws-s3'
|
gem 'aws-s3'
|
||||||
gem 'parka'
|
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'ronn'
|
gem 'ronn'
|
||||||
gem 'fakefs', '~> 0.3.2'
|
gem 'fakefs', '~> 0.3.2'
|
||||||
|
|||||||
+1
-11
@@ -1,8 +1,7 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.40.0)
|
foreman (0.44.0)
|
||||||
term-ansicolor (~> 1.0.7)
|
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
@@ -13,7 +12,6 @@ GEM
|
|||||||
mime-types
|
mime-types
|
||||||
xml-simple
|
xml-simple
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
crack (0.1.8)
|
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
fakefs (0.3.2)
|
fakefs (0.3.2)
|
||||||
hpricot (0.8.6)
|
hpricot (0.8.6)
|
||||||
@@ -21,15 +19,9 @@ GEM
|
|||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
multi_json (1.0.4)
|
multi_json (1.0.4)
|
||||||
mustache (0.11.2)
|
mustache (0.11.2)
|
||||||
parka (0.6.2)
|
|
||||||
crack
|
|
||||||
rest-client
|
|
||||||
thor
|
|
||||||
posix-spawn (0.3.6)
|
posix-spawn (0.3.6)
|
||||||
rake (0.9.2.2)
|
rake (0.9.2.2)
|
||||||
rdiscount (1.6.5)
|
rdiscount (1.6.5)
|
||||||
rest-client (1.6.1)
|
|
||||||
mime-types (>= 1.16)
|
|
||||||
ronn (0.7.3)
|
ronn (0.7.3)
|
||||||
hpricot (>= 0.8.2)
|
hpricot (>= 0.8.2)
|
||||||
mustache (>= 0.7.0)
|
mustache (>= 0.7.0)
|
||||||
@@ -47,7 +39,6 @@ GEM
|
|||||||
multi_json (~> 1.0.3)
|
multi_json (~> 1.0.3)
|
||||||
simplecov-html (~> 0.5.3)
|
simplecov-html (~> 0.5.3)
|
||||||
simplecov-html (0.5.3)
|
simplecov-html (0.5.3)
|
||||||
term-ansicolor (1.0.7)
|
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
win32console (1.3.0-x86-mingw32)
|
win32console (1.3.0-x86-mingw32)
|
||||||
xml-simple (1.0.15)
|
xml-simple (1.0.15)
|
||||||
@@ -61,7 +52,6 @@ DEPENDENCIES
|
|||||||
aws-s3
|
aws-s3
|
||||||
fakefs (~> 0.3.2)
|
fakefs (~> 0.3.2)
|
||||||
foreman!
|
foreman!
|
||||||
parka
|
|
||||||
posix-spawn (~> 0.3.6)
|
posix-spawn (~> 0.3.6)
|
||||||
rake
|
rake
|
||||||
ronn
|
ronn
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Manage Procfile-based applications
|
|||||||
David Dollar
|
David Dollar
|
||||||
|
|
||||||
#### Patches contributed by
|
#### Patches contributed by
|
||||||
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, John Firebaugh, 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
|
[Contributor List](https://github.com/ddollar/foreman/contributors)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<%
|
||||||
|
app_names = []
|
||||||
|
engine.procfile.entries.each do |process|
|
||||||
|
next if (conc = self.concurrency[process.name]) < 1
|
||||||
|
1.upto(self.concurrency[process.name]) do |num|
|
||||||
|
port = engine.port_for(process, num, self.port)
|
||||||
|
name = if (conc > 1); "#{process.name}-#{num}" else process.name; end
|
||||||
|
environment = (engine.environment.keys.sort.map{ |var| %{#{var.upcase}="#{engine.environment[var]}"} } + [%{PORT="#{port}"}])
|
||||||
|
app_name = "#{app}-#{name}"
|
||||||
|
app_names << app_name
|
||||||
|
%>
|
||||||
|
[program:<%= app_name %>]
|
||||||
|
command=<%= process.command %>
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=<%= log_root %>/<%=process.name%>-<%=num%>-out.log
|
||||||
|
stderr_logfile=<%= log_root %>/<%=process.name%>-<%=num%>-err.log
|
||||||
|
user=<%= user %>
|
||||||
|
directory=<%= engine.directory %>
|
||||||
|
environment=<%= environment.join(',') %><%
|
||||||
|
end
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
|
||||||
|
[group:<%= app %>]
|
||||||
|
programs=<%= app_names.join(',') %>
|
||||||
+1
-2
@@ -16,8 +16,7 @@ Gem::Specification.new do |gem|
|
|||||||
gem.files = Dir["**/*"].select { |d| d =~ %r{^(README|bin/|data/|ext/|lib/|spec/|test/)} }
|
gem.files = Dir["**/*"].select { |d| d =~ %r{^(README|bin/|data/|ext/|lib/|spec/|test/)} }
|
||||||
gem.files << "man/foreman.1"
|
gem.files << "man/foreman.1"
|
||||||
|
|
||||||
gem.add_dependency 'term-ansicolor', '~> 1.0.7'
|
gem.add_dependency 'thor', '>= 0.13.6'
|
||||||
gem.add_dependency 'thor', '>= 0.13.6'
|
|
||||||
|
|
||||||
if ENV["PLATFORM"] == "java"
|
if ENV["PLATFORM"] == "java"
|
||||||
gem.add_dependency "posix-spawn", "~> 0.3.6"
|
gem.add_dependency "posix-spawn", "~> 0.3.6"
|
||||||
|
|||||||
+5
-1
@@ -83,7 +83,11 @@ private ######################################################################
|
|||||||
end
|
end
|
||||||
|
|
||||||
def procfile
|
def procfile
|
||||||
options[:procfile] || "Procfile"
|
case
|
||||||
|
when options[:procfile] then options[:procfile]
|
||||||
|
when options[:app_root] then File.expand_path(File.join(options[:app_root], "Procfile"))
|
||||||
|
else "Procfile"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def error(message)
|
def error(message)
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
require "foreman"
|
||||||
|
|
||||||
|
module Foreman::Color
|
||||||
|
|
||||||
|
ANSI = {
|
||||||
|
:reset => 0,
|
||||||
|
:black => 30,
|
||||||
|
:red => 31,
|
||||||
|
:green => 32,
|
||||||
|
:yellow => 33,
|
||||||
|
:blue => 34,
|
||||||
|
:magenta => 35,
|
||||||
|
:cyan => 36,
|
||||||
|
:white => 37,
|
||||||
|
:bright_black => 30,
|
||||||
|
:bright_red => 31,
|
||||||
|
:bright_green => 32,
|
||||||
|
:bright_yellow => 33,
|
||||||
|
:bright_blue => 34,
|
||||||
|
:bright_magenta => 35,
|
||||||
|
:bright_cyan => 36,
|
||||||
|
:bright_white => 37,
|
||||||
|
}
|
||||||
|
|
||||||
|
def self.enable(io)
|
||||||
|
io.extend(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def color?
|
||||||
|
return false unless self.respond_to?(:isatty)
|
||||||
|
self.isatty && ENV["TERM"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def color(name)
|
||||||
|
return "" unless color?
|
||||||
|
return "" unless ansi = ANSI[name.to_sym]
|
||||||
|
"\e[#{ansi}m"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
+33
-34
@@ -1,10 +1,10 @@
|
|||||||
require "foreman"
|
require "foreman"
|
||||||
|
require "foreman/color"
|
||||||
require "foreman/process"
|
require "foreman/process"
|
||||||
require "foreman/procfile"
|
require "foreman/procfile"
|
||||||
require "foreman/utils"
|
require "foreman/utils"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
require "timeout"
|
require "timeout"
|
||||||
require "term/ansicolor"
|
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
require "thread"
|
require "thread"
|
||||||
|
|
||||||
@@ -15,18 +15,19 @@ class Foreman::Engine
|
|||||||
attr_reader :directory
|
attr_reader :directory
|
||||||
attr_reader :options
|
attr_reader :options
|
||||||
|
|
||||||
extend Term::ANSIColor
|
COLORS = %w( cyan yellow green magenta red blue intense_cyan intense_yellow
|
||||||
|
intense_green intense_magenta intense_red, intense_blue )
|
||||||
|
|
||||||
COLORS = [ cyan, yellow, green, magenta, red, blue,
|
Foreman::Color.enable($stdout)
|
||||||
intense_cyan, intense_yellow, intense_green, intense_magenta,
|
|
||||||
intense_red, intense_blue ]
|
|
||||||
|
|
||||||
def initialize(procfile, options={})
|
def initialize(procfile, options={})
|
||||||
@procfile = Foreman::Procfile.new(procfile)
|
@procfile = Foreman::Procfile.new(procfile)
|
||||||
@directory = options[:app_root] || File.expand_path(File.dirname(procfile))
|
@directory = options[:app_root] || File.expand_path(File.dirname(procfile))
|
||||||
@options = options.dup
|
@options = options.dup
|
||||||
@environment = read_environment_files(options[:env])
|
|
||||||
@output_mutex = Mutex.new
|
@output_mutex = Mutex.new
|
||||||
|
|
||||||
|
@options[:env] ||= default_env
|
||||||
|
@environment = read_environment_files(@options[:env])
|
||||||
end
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
@@ -52,6 +53,22 @@ class Foreman::Engine
|
|||||||
environment.each { |k,v| ENV[k] = v }
|
environment.each { |k,v| ENV[k] = v }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.read_environment(filename)
|
||||||
|
return {} unless File.exists?(filename)
|
||||||
|
|
||||||
|
File.read(filename).split("\n").inject({}) do |hash, line|
|
||||||
|
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
||||||
|
key, val = [$1, $2]
|
||||||
|
case val
|
||||||
|
when /\A'(.*)'\z/ then hash[key] = $1
|
||||||
|
when /\A"(.*)"\z/ then hash[key] = $1.gsub(/\\(.)/, '\1')
|
||||||
|
else hash[key] = val
|
||||||
|
end
|
||||||
|
end
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private ######################################################################
|
private ######################################################################
|
||||||
|
|
||||||
def spawn_processes
|
def spawn_processes
|
||||||
@@ -128,11 +145,11 @@ private ######################################################################
|
|||||||
rescue Errno::ECHILD
|
rescue Errno::ECHILD
|
||||||
end
|
end
|
||||||
|
|
||||||
def info(message, name="system", color=Term::ANSIColor.white)
|
def info(message, name="system", color=:white)
|
||||||
output = ""
|
output = ""
|
||||||
output += color
|
output += $stdout.color(color)
|
||||||
output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "
|
output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "
|
||||||
output += Term::ANSIColor.reset
|
output += $stdout.color(:reset)
|
||||||
output += message.chomp
|
output += message.chomp
|
||||||
puts output
|
puts output
|
||||||
end
|
end
|
||||||
@@ -182,8 +199,8 @@ private ######################################################################
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assign_colors
|
def assign_colors
|
||||||
procfile.entries.each do |entry|
|
procfile.entries.each_with_index do |entry, idx|
|
||||||
colors[entry.name] = next_color
|
colors[entry.name] = COLORS[idx % COLORS.length]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -191,38 +208,20 @@ private ######################################################################
|
|||||||
readers.invert[reader]
|
readers.invert[reader]
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_color
|
|
||||||
@current_color ||= -1
|
|
||||||
@current_color += 1
|
|
||||||
@current_color = 0 if COLORS.length < @current_color
|
|
||||||
COLORS[@current_color]
|
|
||||||
end
|
|
||||||
|
|
||||||
def read_environment_files(filenames)
|
def read_environment_files(filenames)
|
||||||
environment = {}
|
environment = {}
|
||||||
|
|
||||||
(filenames || "").split(",").map(&:strip).each do |filename|
|
(filenames || "").split(",").map(&:strip).each do |filename|
|
||||||
error "No such file: #{filename}" unless File.exists?(filename)
|
error "No such file: #{filename}" unless File.exists?(filename)
|
||||||
environment.merge!(read_environment(filename))
|
environment.merge!(Foreman::Engine.read_environment(filename))
|
||||||
end
|
end
|
||||||
|
|
||||||
environment.merge!(read_environment(".env")) unless filenames
|
|
||||||
environment
|
environment
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_environment(filename)
|
def default_env
|
||||||
return {} unless File.exists?(filename)
|
env = File.join(directory, ".env")
|
||||||
|
File.exists?(env) ? env : ""
|
||||||
File.read(filename).split("\n").inject({}) do |hash, line|
|
|
||||||
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
|
||||||
key, val = [$1, $2]
|
|
||||||
case val
|
|
||||||
when /\A'(.*)'\z/ then hash[key] = $1
|
|
||||||
when /\A"(.*)"\z/ then hash[key] = $1.gsub(/\\(.)/, '\1')
|
|
||||||
else hash[key] = val
|
|
||||||
end
|
|
||||||
end
|
|
||||||
hash
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,3 +30,5 @@ require "foreman/export/inittab"
|
|||||||
require "foreman/export/upstart"
|
require "foreman/export/upstart"
|
||||||
require "foreman/export/bluepill"
|
require "foreman/export/bluepill"
|
||||||
require "foreman/export/runit"
|
require "foreman/export/runit"
|
||||||
|
require "foreman/export/supervisord"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
require "erb"
|
||||||
|
require "foreman/export"
|
||||||
|
|
||||||
|
class Foreman::Export::Supervisord < Foreman::Export::Base
|
||||||
|
|
||||||
|
def export
|
||||||
|
error("Must specify a location") unless location
|
||||||
|
|
||||||
|
FileUtils.mkdir_p location
|
||||||
|
|
||||||
|
app = self.app || File.basename(engine.directory)
|
||||||
|
user = self.user || app
|
||||||
|
log_root = self.log || "/var/log/#{app}"
|
||||||
|
template_root = self.template
|
||||||
|
|
||||||
|
Dir["#{location}/#{app}*.conf"].each do |file|
|
||||||
|
say "cleaning up: #{file}"
|
||||||
|
FileUtils.rm(file)
|
||||||
|
end
|
||||||
|
|
||||||
|
app_template = export_template("supervisord", "app.conf.erb", template_root)
|
||||||
|
app_config = ERB.new(app_template, 0, '<').result(binding)
|
||||||
|
write_file "#{location}/#{app}.conf", app_config
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
module Foreman
|
module Foreman
|
||||||
|
|
||||||
VERSION = "0.40.0"
|
VERSION = "0.44.0"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+9
-1
@@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
.
|
.
|
||||||
.TH "FOREMAN" "1" "February 2012" "Foreman 0.39.0" "Foreman Manual"
|
.TH "FOREMAN" "1" "April 2012" "Foreman 0.43.0" "Foreman Manual"
|
||||||
.
|
.
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
\fBforeman\fR \- manage Procfile\-based applications
|
\fBforeman\fR \- manage Procfile\-based applications
|
||||||
@@ -35,6 +35,14 @@ The following options control how the application is run:
|
|||||||
Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR
|
Specify the number of each process type to run\. The value passed in should be in the format \fBprocess=num,process=num\fR
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-e\fR, \fB\-\-env\fR
|
||||||
|
Specify one or more \.env files to load
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-f\fR, \fB\-\-procfile\fR
|
||||||
|
Specify an alternate Procfile to load, implies \fB\-d\fR at the Procfile root\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fB\-p\fR, \fB\-\-port\fR
|
\fB\-p\fR, \fB\-\-port\fR
|
||||||
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
Specify which port to use as the base for this application\. Should be a multiple of 1000\.
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ The following options control how the application is run:
|
|||||||
Specify the number of each process type to run. The value passed in
|
Specify the number of each process type to run. The value passed in
|
||||||
should be in the format `process=num,process=num`
|
should be in the format `process=num,process=num`
|
||||||
|
|
||||||
|
* `-e`, `--env`:
|
||||||
|
Specify one or more .env files to load
|
||||||
|
|
||||||
|
* `-f`, `--procfile`:
|
||||||
|
Specify an alternate Procfile to load, implies `-d` at the Procfile root.
|
||||||
|
|
||||||
* `-p`, `--port`:
|
* `-p`, `--port`:
|
||||||
Specify which port to use as the base for this application. Should be
|
Specify which port to use as the base for this application. Should be
|
||||||
a multiple of 1000.
|
a multiple of 1000.
|
||||||
|
|||||||
@@ -34,6 +34,15 @@ describe "Foreman::CLI", :fakefs do
|
|||||||
subject.start("alpha")
|
subject.start("alpha")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "with an alternate root" do
|
||||||
|
it "reads the Procfile from that root" do
|
||||||
|
write_procfile "/some/app/Procfile"
|
||||||
|
mock(Foreman::Procfile).new("/some/app/Procfile")
|
||||||
|
mock.instance_of(Foreman::Engine).start
|
||||||
|
foreman %{ start -d /some/app }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "export" do
|
describe "export" do
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
require "foreman/color"
|
||||||
|
|
||||||
|
describe Foreman::Color do
|
||||||
|
|
||||||
|
let(:io) { Object.new }
|
||||||
|
|
||||||
|
it "should extend an object with colorization" do
|
||||||
|
Foreman::Color.enable(io)
|
||||||
|
io.should respond_to(:color)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not colorize if the object does not respond to isatty" do
|
||||||
|
mock(io).respond_to?(:isatty) { false }
|
||||||
|
Foreman::Color.enable(io)
|
||||||
|
io.color(:white).should == ""
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not colorize if the object is not a tty" do
|
||||||
|
mock(io).isatty { false }
|
||||||
|
Foreman::Color.enable(io)
|
||||||
|
io.color(:white).should == ""
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should colorize if the object is a tty" do
|
||||||
|
mock(io).isatty { true }
|
||||||
|
Foreman::Color.enable(io)
|
||||||
|
io.color(:white).should == "\e[37m"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -49,6 +49,14 @@ describe "Foreman::Engine", :fakefs do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "directories" do
|
||||||
|
it "has the directory default relative to the Procfile" do
|
||||||
|
write_procfile "/some/app/Procfile"
|
||||||
|
engine = Foreman::Engine.new("/some/app/Procfile")
|
||||||
|
engine.directory.should == "/some/app"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "environment" do
|
describe "environment" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
write_procfile
|
write_procfile
|
||||||
@@ -97,6 +105,15 @@ describe "Foreman::Engine", :fakefs do
|
|||||||
engine.environment.should == {"FOO"=>"qoo"}
|
engine.environment.should == {"FOO"=>"qoo"}
|
||||||
engine.start
|
engine.start
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should be loaded relative to the Procfile" do
|
||||||
|
FileUtils.mkdir_p "/some/app"
|
||||||
|
File.open("/some/app/.env", "w") { |f| f.puts("FOO=qoo") }
|
||||||
|
write_procfile "/some/app/Procfile"
|
||||||
|
engine = Foreman::Engine.new("/some/app/Procfile")
|
||||||
|
engine.environment.should == {"FOO"=>"qoo"}
|
||||||
|
engine.start
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "utf8" do
|
describe "utf8" do
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
require "foreman/engine"
|
||||||
|
require "foreman/export/supervisord"
|
||||||
|
require "tmpdir"
|
||||||
|
|
||||||
|
describe Foreman::Export::Supervisord, :fakefs do
|
||||||
|
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
||||||
|
let(:engine) { Foreman::Engine.new(procfile) }
|
||||||
|
let(:options) { Hash.new }
|
||||||
|
let(:supervisord) { Foreman::Export::Supervisord.new("/tmp/init", engine, options) }
|
||||||
|
|
||||||
|
before(:each) { load_export_templates_into_fakefs("supervisord") }
|
||||||
|
before(:each) { stub(supervisord).say }
|
||||||
|
|
||||||
|
it "exports to the filesystem" do
|
||||||
|
supervisord.export
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "cleans up if exporting into an existing dir" do
|
||||||
|
mock(FileUtils).rm("/tmp/init/app.conf")
|
||||||
|
supervisord.export
|
||||||
|
supervisord.export
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with concurrency" do
|
||||||
|
let(:options) { Hash[:concurrency => "alpha=2"] }
|
||||||
|
|
||||||
|
it "exports to the filesystem with concurrency" do
|
||||||
|
supervisord.export
|
||||||
|
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with alternate templates" do
|
||||||
|
let(:template_root) { "/tmp/alternate" }
|
||||||
|
let(:supervisord) { Foreman::Export::Supervisord.new("/tmp/init", engine, :template => template_root) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
FileUtils.mkdir_p template_root
|
||||||
|
File.open("#{template_root}/app.conf.erb", "w") { |f| f.puts "alternate_template" }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can export with alternate template files" do
|
||||||
|
supervisord.export
|
||||||
|
File.read("/tmp/init/app.conf").should == "alternate_template\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with alternate templates from home dir" do
|
||||||
|
let(:default_template_root) {File.expand_path("#{ENV['HOME']}/.foreman/templates")}
|
||||||
|
|
||||||
|
before do
|
||||||
|
ENV['_FOREMAN_SPEC_HOME'] = ENV['HOME']
|
||||||
|
ENV['HOME'] = "/home/appuser"
|
||||||
|
FileUtils.mkdir_p default_template_root
|
||||||
|
File.open("#{default_template_root}/app.conf.erb", "w") { |f| f.puts "default_alternate_template" }
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
ENV['HOME'] = ENV.delete('_FOREMAN_SPEC_HOME')
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can export with alternate template files" do
|
||||||
|
supervisord.export
|
||||||
|
File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "environment export" do
|
||||||
|
it "correctly translates environment when exporting" do
|
||||||
|
File.open("/tmp/supervisord_env", "w") { |f| f.puts("QUEUE=fastqueue,slowqueue\nVERBOSE=1") }
|
||||||
|
|
||||||
|
engine = Foreman::Engine.new(procfile,:env => "/tmp/supervisord_env")
|
||||||
|
supervisor = Foreman::Export::Supervisord.new("/tmp/init", engine, options)
|
||||||
|
stub(supervisor).say
|
||||||
|
|
||||||
|
supervisor.export
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-env-with-comma.conf")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
[program:app-alpha-1]
|
||||||
|
command=./alpha
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/alpha-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/alpha-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=PORT="5000"
|
||||||
|
[program:app-alpha-2]
|
||||||
|
command=./alpha
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/alpha-2-out.log
|
||||||
|
stderr_logfile=/var/log/app/alpha-2-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=PORT="5001"
|
||||||
|
|
||||||
|
[group:app]
|
||||||
|
programs=app-alpha-1,app-alpha-2
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
[program:app-alpha]
|
||||||
|
command=./alpha
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/alpha-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/alpha-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=QUEUE="fastqueue,slowqueue",VERBOSE="1",PORT="5000"
|
||||||
|
[program:app-bravo]
|
||||||
|
command=./bravo
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/bravo-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/bravo-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=QUEUE="fastqueue,slowqueue",VERBOSE="1",PORT="5100"
|
||||||
|
|
||||||
|
[group:app]
|
||||||
|
programs=app-alpha,app-bravo
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
[program:app-alpha]
|
||||||
|
command=./alpha
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/alpha-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/alpha-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=FOO="bar",PORT="5000"
|
||||||
|
[program:app-bravo]
|
||||||
|
command=./bravo
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/bravo-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/bravo-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=FOO="bar",PORT="5100"
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
[program:app-alpha]
|
||||||
|
command=./alpha
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/alpha-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/alpha-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=PORT="5000"
|
||||||
|
[program:app-bravo]
|
||||||
|
command=./bravo
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=QUIT
|
||||||
|
stdout_logfile=/var/log/app/bravo-1-out.log
|
||||||
|
stderr_logfile=/var/log/app/bravo-1-err.log
|
||||||
|
user=app
|
||||||
|
directory=/tmp/app
|
||||||
|
environment=PORT="5100"
|
||||||
|
|
||||||
|
[group:app]
|
||||||
|
programs=app-alpha,app-bravo
|
||||||
@@ -27,14 +27,6 @@ task :pages => "man:commit" do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Generate an authors list"
|
|
||||||
task :authors do
|
|
||||||
authors = %x{ git log --pretty=format:"%an" | sort -u }.split("\n")
|
|
||||||
readme = File.read("README.md")
|
|
||||||
readme.gsub!(/#### Patches contributed by\n([^\n]*)\n/m, "#### Patches contributed by\n#{authors.join(", ")}\n")
|
|
||||||
File.open("README.md", "w") { |f| f.print readme }
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest_release
|
def latest_release
|
||||||
latest = File.read("Changelog.md").split("\n").first.split(" ")[1]
|
latest = File.read("Changelog.md").split("\n").first.split(" ")[1]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user