Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
180f63624e | ||
|
|
13fd1188ad | ||
|
|
92c2b15785 | ||
|
|
4a2d7565b7 | ||
|
|
49720e0458 | ||
|
|
c4de19f4da | ||
|
|
490c8b73bf | ||
|
|
f622f43cf4 | ||
|
|
9ab701f5b9 | ||
|
|
1a5d2428b9 | ||
|
|
564aa740e1 | ||
|
|
95115f4e78 |
17
Gemfile
17
Gemfile
@@ -1,18 +1,3 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
group :development do
|
||||
gem 'parka'
|
||||
gem 'rake'
|
||||
gem 'ronn'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'fakefs', '~> 0.2.1'
|
||||
gem 'rcov', '~> 0.9.8'
|
||||
gem 'rr', '~> 1.0.2'
|
||||
gem 'rspec', '~> 2.0.0'
|
||||
end
|
||||
|
||||
gem 'json', '~> 1.5.1'
|
||||
gem 'term-ansicolor', '~> 1.0.5'
|
||||
gem 'thor', '>= 0.13.6'
|
||||
gemspec
|
||||
|
||||
18
Gemfile.lock
18
Gemfile.lock
@@ -1,19 +1,27 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
foreman (0.14.0)
|
||||
term-ansicolor (~> 1.0.5)
|
||||
thor (>= 0.13.6)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
crack (0.1.8)
|
||||
diff-lcs (1.1.2)
|
||||
fakefs (0.2.1)
|
||||
hpricot (0.8.2)
|
||||
json (1.5.1)
|
||||
mime-types (1.16)
|
||||
mustache (0.11.2)
|
||||
parka (0.3.1)
|
||||
parka (0.6.2)
|
||||
crack
|
||||
rest-client
|
||||
thor
|
||||
rake (0.8.7)
|
||||
rcov (0.9.8)
|
||||
rdiscount (1.6.5)
|
||||
rest-client (1.6.0)
|
||||
rest-client (1.6.1)
|
||||
mime-types (>= 1.16)
|
||||
ronn (0.7.3)
|
||||
hpricot (>= 0.8.2)
|
||||
@@ -38,12 +46,10 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
fakefs (~> 0.2.1)
|
||||
json (~> 1.5.1)
|
||||
foreman!
|
||||
parka
|
||||
rake
|
||||
rcov (~> 0.9.8)
|
||||
ronn
|
||||
rr (~> 1.0.2)
|
||||
rspec (~> 2.0.0)
|
||||
term-ansicolor (~> 1.0.5)
|
||||
thor (>= 0.13.6)
|
||||
|
||||
8
Rakefile
8
Rakefile
@@ -33,19 +33,23 @@ task :man do
|
||||
ENV['RONN_MANUAL'] = "Foreman Manual"
|
||||
ENV['RONN_ORGANIZATION'] = "Foreman #{Foreman::VERSION}"
|
||||
sh "ronn -w -s toc -r5 --markdown man/*.ronn"
|
||||
end
|
||||
|
||||
desc "Commit the manual to git"
|
||||
task "man:commit" => :man do
|
||||
sh "git add README.markdown"
|
||||
sh "git commit -m 'update readme' || echo 'nothing to commit'"
|
||||
end
|
||||
|
||||
desc "Generate the Github docs"
|
||||
task :pages => :man do
|
||||
task :pages => "man:commit" do
|
||||
sh %{
|
||||
cp man/foreman.1.html /tmp/foreman.1.html
|
||||
git checkout gh-pages
|
||||
rm ./index.html
|
||||
cp /tmp/foreman.1.html ./index.html
|
||||
git add -u index.html
|
||||
git commit -m "rebuilding man page"
|
||||
git commit -m "saving man page to github docs"
|
||||
git push origin -f gh-pages
|
||||
git checkout master
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ stop on stopping <%= app %>-<%= process.name %>
|
||||
respawn
|
||||
|
||||
chdir <%= engine.directory %>
|
||||
exec su - <%= user %> -c 'export PORT=<%= port %>; <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1'
|
||||
exec su <%= user %> -c 'export PORT=<%= port %>; <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1'
|
||||
|
||||
@@ -16,10 +16,10 @@ Gem::Specification.new do |gem|
|
||||
gem.files = Dir["**/*"].select { |d| d =~ %r{^(README|bin/|data/|ext/|lib/|spec/|test/)} }
|
||||
gem.files << "man/foreman.1"
|
||||
|
||||
gem.add_dependency 'json', '~> 1.5.1'
|
||||
gem.add_dependency 'term-ansicolor', '~> 1.0.5'
|
||||
gem.add_dependency 'thor', '>= 0.13.6'
|
||||
|
||||
gem.add_development_dependency 'parka'
|
||||
gem.add_development_dependency 'rake'
|
||||
gem.add_development_dependency 'ronn'
|
||||
gem.add_development_dependency 'fakefs', '~> 0.2.1'
|
||||
|
||||
@@ -2,6 +2,7 @@ require "foreman"
|
||||
require "foreman/engine"
|
||||
require "foreman/export"
|
||||
require "thor"
|
||||
require "yaml"
|
||||
|
||||
class Foreman::CLI < Thor
|
||||
|
||||
@@ -36,7 +37,6 @@ class Foreman::CLI < Thor
|
||||
check_procfile!
|
||||
|
||||
formatter = case format
|
||||
when "json" then Foreman::Export::JSON
|
||||
when "inittab" then Foreman::Export::Inittab
|
||||
when "upstart" then Foreman::Export::Upstart
|
||||
else error "Unknown export format: #{format}."
|
||||
|
||||
@@ -4,6 +4,5 @@ module Foreman::Export
|
||||
class Exception < ::Exception; end
|
||||
end
|
||||
|
||||
require "foreman/export/json"
|
||||
require "foreman/export/inittab"
|
||||
require "foreman/export/upstart"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
require "foreman/export/base"
|
||||
require "json"
|
||||
|
||||
class Foreman::Export::JSON < Foreman::Export::Base
|
||||
|
||||
def export(fname=nil, options={})
|
||||
processes = engine.processes.values.inject({}) do |hash, process|
|
||||
hash.update(process.name => { "command" => process.command })
|
||||
end
|
||||
puts processes.to_json
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
module Foreman
|
||||
|
||||
VERSION = "0.12.0"
|
||||
VERSION = "0.14.0"
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "FOREMAN" "1" "March 2011" "Foreman 0.12.0.pre1" "Foreman Manual"
|
||||
.TH "FOREMAN" "1" "May 2011" "Foreman 0.13.0" "Foreman Manual"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBforeman\fR \- manage Procfile\-based applications
|
||||
@@ -75,9 +75,6 @@ Specify an alternate location for the application\'s Procfile\. This file\'s con
|
||||
foreman currently supports the following output formats:
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
json
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
inittab
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
@@ -85,19 +82,6 @@ upstart
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "JSON EXPORT"
|
||||
Will export your processes as JSON:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
{ "web": { "command": "bundle exec thin start" } }
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "INITTAB EXPORT"
|
||||
Will export a chunk of inittab\-compatible configuration:
|
||||
.
|
||||
|
||||
@@ -75,18 +75,10 @@ These options control all modes of foreman's operation.
|
||||
|
||||
foreman currently supports the following output formats:
|
||||
|
||||
* json
|
||||
|
||||
* inittab
|
||||
|
||||
* upstart
|
||||
|
||||
## JSON EXPORT
|
||||
|
||||
Will export your processes as JSON:
|
||||
|
||||
{ "web": { "command": "bundle exec thin start" } }
|
||||
|
||||
## INITTAB EXPORT
|
||||
|
||||
Will export a chunk of inittab-compatible configuration:
|
||||
|
||||
@@ -1,2 +1,21 @@
|
||||
require "spec_helper"
|
||||
require "foreman/export/upstart"
|
||||
|
||||
describe Foreman::Export::Upstart do
|
||||
let(:engine) { Foreman::Engine.new(write_procfile) }
|
||||
let(:upstart) { Foreman::Export::Upstart.new(engine) }
|
||||
|
||||
before(:each) { load_export_templates_into_fakefs("upstart") }
|
||||
before(:each) { stub(upstart).say }
|
||||
|
||||
it "exports to the filesystem" do
|
||||
upstart.export("/tmp/init")
|
||||
|
||||
File.read("/tmp/init/foreman.conf").should == example_export_file("upstart/foreman.conf")
|
||||
File.read("/tmp/init/foreman-alpha.conf").should == example_export_file("upstart/foreman-alpha.conf")
|
||||
File.read("/tmp/init/foreman-alpha-1.conf").should == example_export_file("upstart/foreman-alpha-1.conf")
|
||||
File.read("/tmp/init/foreman-alpha-2.conf").should == example_export_file("upstart/foreman-alpha-2.conf")
|
||||
File.read("/tmp/init/foreman-bravo.conf").should == example_export_file("upstart/foreman.bravo.conf")
|
||||
File.read("/tmp/init/foreman-bravo-1.conf").should == example_export_file("upstart/foreman-bravo-1.conf")
|
||||
end
|
||||
end
|
||||
|
||||
6
spec/resources/export/upstart/foreman-alpha-1.conf
Normal file
6
spec/resources/export/upstart/foreman-alpha-1.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
start on starting foreman-alpha
|
||||
stop on stopping foreman-alpha
|
||||
respawn
|
||||
|
||||
chdir /Users/david/Code/foreman
|
||||
exec su foreman -c 'export PORT=5000; ./alpha >> /var/log/foreman/alpha-1.log 2>&1'
|
||||
6
spec/resources/export/upstart/foreman-alpha-2.conf
Normal file
6
spec/resources/export/upstart/foreman-alpha-2.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
start on starting foreman-alpha
|
||||
stop on stopping foreman-alpha
|
||||
respawn
|
||||
|
||||
chdir /Users/david/Code/foreman
|
||||
exec su foreman -c 'export PORT=5001; ./alpha >> /var/log/foreman/alpha-2.log 2>&1'
|
||||
2
spec/resources/export/upstart/foreman-alpha.conf
Normal file
2
spec/resources/export/upstart/foreman-alpha.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
start on starting foreman
|
||||
stop on stopping foreman
|
||||
6
spec/resources/export/upstart/foreman-bravo-1.conf
Normal file
6
spec/resources/export/upstart/foreman-bravo-1.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
start on starting foreman-bravo
|
||||
stop on stopping foreman-bravo
|
||||
respawn
|
||||
|
||||
chdir /Users/david/Code/foreman
|
||||
exec su foreman -c 'export PORT=5100; ./bravo >> /var/log/foreman/bravo-1.log 2>&1'
|
||||
2
spec/resources/export/upstart/foreman.bravo.conf
Normal file
2
spec/resources/export/upstart/foreman.bravo.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
start on starting foreman
|
||||
stop on stopping foreman
|
||||
8
spec/resources/export/upstart/foreman.conf
Normal file
8
spec/resources/export/upstart/foreman.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
pre-start script
|
||||
|
||||
bash << "EOF"
|
||||
mkdir -p /var/log/foreman
|
||||
chown -R foreman /var/log/foreman
|
||||
EOF
|
||||
|
||||
end script
|
||||
@@ -29,6 +29,27 @@ def write_procfile(procfile="Procfile")
|
||||
file.puts "alpha: ./alpha"
|
||||
file.puts "bravo: ./bravo"
|
||||
end
|
||||
File.expand_path(procfile)
|
||||
end
|
||||
|
||||
def load_export_templates_into_fakefs(type)
|
||||
FakeFS.deactivate!
|
||||
files = Dir[File.expand_path("../../data/export/#{type}/**", __FILE__)].inject({}) do |hash, file|
|
||||
hash.update(file => File.read(file))
|
||||
end
|
||||
FakeFS.activate!
|
||||
files.each do |filename, contents|
|
||||
File.open(filename, "w") do |f|
|
||||
f.puts contents
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def example_export_file(filename)
|
||||
FakeFS.deactivate!
|
||||
data = File.read(File.expand_path("../resources/export/#{filename}", __FILE__))
|
||||
FakeFS.activate!
|
||||
data
|
||||
end
|
||||
|
||||
Rspec.configure do |config|
|
||||
|
||||
Reference in New Issue
Block a user