Compare commits

...

20 Commits

Author SHA1 Message Date
David Dollar
0033f9caeb 0.42.0 2012-04-18 13:02:51 -04:00
David Dollar
74839800a9 Merge pull request #181 from technomancy/master
Public read_environment
2012-04-18 10:01:38 -07:00
Phil Hagelberg
b75337e21e Move read_environment to a public class method. 2012-04-18 09:56:17 -07:00
David Dollar
d94f941189 update gemfile.lock 2012-04-18 12:49:33 -04:00
David Dollar
0b34f067cb Revert "Merge pull request #176 from rtyler/feature/156-foreman-stop-command"
Rewriting using a better Process API

This reverts commit dbe51832b0, reversing
changes made to 69216b4c5e.
2012-04-18 12:48:51 -04:00
David Dollar
dbe51832b0 Merge pull request #176 from rtyler/feature/156-foreman-stop-command
Adding #stop method to Foreman::Engine
2012-04-11 10:29:54 -07:00
R. Tyler Croy
3a2a53be95 Remove ALL_PROCESSES and default the name arguments to #start/#stop to nil 2012-04-11 10:25:58 -07:00
R. Tyler Croy
b2bf95479e Refactor #stop to reference ALL_PROCESSES for a bit clearer readability 2012-04-10 20:35:59 -07:00
R. Tyler Croy
48f764e347 Refactor #spawn_processes into #start(name)
When passed nil (aka ALL_PROCESSES) #start will start all processes in the
Procfile as per existing behavior
2012-04-10 20:35:59 -07:00
R. Tyler Croy
de62d0655e Re-name the main Foreman::Engine method to #run to avoid a name collision with #start(name) 2012-04-10 20:35:59 -07:00
R. Tyler Croy
38aecff886 When executing #stop(nil), all processes should be sent the signal 2012-04-10 20:35:58 -07:00
R. Tyler Croy
e4a3215257 Re-implement #terminate_gracefully with #stop(name) 2012-04-10 20:19:23 -07:00
R. Tyler Croy
c705b5fbef Add #stop method on Foreman::Engine for stopping certain named processes
This will make embedding foreman "nicer" since the embedder can then stop
a specific process (e.g. turning off a service for an integration fail-over test)
2012-04-10 20:10:51 -07:00
David Dollar
69216b4c5e Merge pull request #171 from technomancy/0.41.0-deparkaed
Drop parka dependency to make things easier on the build slaves.
2012-03-26 15:05:35 -07:00
Phil Hagelberg
5d2930745a Drop parka dependency to make things easier on the build slaves. 2012-03-26 15:01:04 -07:00
David Dollar
8fc3d1ef24 Merge pull request #161 from leahpar/master
Supervisord Support (Update & Bugfix)
2012-03-16 18:47:15 -07:00
David Dollar
d33e4fb0ed update changelog 2012-03-16 16:36:16 -04:00
Raphael Randschau
1217ef1b56 fix typo 2012-03-05 15:51:10 +01:00
Raphael Randschau
c9943d70ec add group support for supervisord 2012-03-05 15:48:40 +01:00
Raphael Randschau
08dca57eb4 fix enviroment export 2012-02-25 17:24:27 +01:00
9 changed files with 42 additions and 34 deletions

View File

@@ -1,3 +1,8 @@
## 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]

View File

@@ -12,7 +12,6 @@ end
group :development do
gem 'aws-s3'
gem 'parka'
gem 'rake'
gem 'ronn'
gem 'fakefs', '~> 0.3.2'

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.41.0)
foreman (0.42.0)
thor (>= 0.13.6)
GEM
@@ -12,7 +12,6 @@ GEM
mime-types
xml-simple
builder (3.0.0)
crack (0.1.8)
diff-lcs (1.1.3)
fakefs (0.3.2)
hpricot (0.8.6)
@@ -20,15 +19,9 @@ GEM
mime-types (1.16)
multi_json (1.0.4)
mustache (0.11.2)
parka (0.6.2)
crack
rest-client
thor
posix-spawn (0.3.6)
rake (0.9.2.2)
rdiscount (1.6.5)
rest-client (1.6.1)
mime-types (>= 1.16)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
@@ -59,7 +52,6 @@ DEPENDENCIES
aws-s3
fakefs (~> 0.3.2)
foreman!
parka
posix-spawn (~> 0.3.6)
rake
ronn

View File

@@ -1,12 +1,15 @@
<%
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.each_pair { |var,env| "#{var.upcase}=#{env}" }.to_a << "PORT=#{port}")
environment = (engine.environment.map{ |var,env| "#{var.upcase}=#{env}" } + ["PORT=#{port}"])
app_name = "#{app}-#{name}"
app_names << app_name
%>
[program:<%= app %>-<%= name %>]
[program:<%= app_name %>]
command=<%= process.command %>
autostart=true
autorestart=true
@@ -18,4 +21,7 @@ directory=<%= engine.directory %>
environment=<%= environment.join(',') %><%
end
end
%>
%>
[group:<%= app %>]
programs=<%= app_names.join(',') %>

View File

@@ -51,6 +51,22 @@ class Foreman::Engine
environment.each { |k,v| ENV[k] = v }
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 ######################################################################
def spawn_processes
@@ -195,26 +211,10 @@ private ######################################################################
(filenames || "").split(",").map(&:strip).each do |filename|
error "No such file: #{filename}" unless File.exists?(filename)
environment.merge!(read_environment(filename))
environment.merge!(Foreman::Engine.read_environment(filename))
end
environment.merge!(read_environment(".env")) unless filenames
environment.merge!(Foreman::Engine.read_environment(".env")) unless filenames
environment
end
def 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
end

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.41.0"
VERSION = "0.42.0"
end

View File

@@ -30,7 +30,7 @@ describe Foreman::Export::Supervisord, :fakefs do
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
@@ -46,7 +46,7 @@ describe Foreman::Export::Supervisord, :fakefs do
it "can export with alternate template files" do
supervisord.export
File.read("/tmp/init/app.conf").should == "alternate_template\n"
end
end

View File

@@ -19,3 +19,6 @@ 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

View File

@@ -19,3 +19,6 @@ stderr_logfile=/var/log/app/bravo-1-err.log
user=app
directory=/tmp/app
environment=PORT=5100
[group:app]
programs=app-alpha,app-bravo