Compare commits
33
Commits
v0.34.0
...
v0.37.0.pre2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2995a605b4 | ||
|
|
ef280e802d | ||
|
|
8a9001842c | ||
|
|
8a8d31eb43 | ||
|
|
3e98170878 | ||
|
|
3d84de3062 | ||
|
|
9cc0afca49 | ||
|
|
7a25d3ac5a | ||
|
|
db1a5df354 | ||
|
|
e137596ce0 | ||
|
|
c9042c5aae | ||
|
|
550adc8070 | ||
|
|
fbdde3e62a | ||
|
|
e161ecb630 | ||
|
|
853a88dfbf | ||
|
|
b4cab08327 | ||
|
|
a008886bd0 | ||
|
|
c62f892ff6 | ||
|
|
d885e019b3 | ||
|
|
cfd337b44d | ||
|
|
1485eeb859 | ||
|
|
e0b5928e88 | ||
|
|
a73dce5405 | ||
|
|
2abddb42b3 | ||
|
|
d961a32cfe | ||
|
|
2bfc065c1d | ||
|
|
fbe3d4ec69 | ||
|
|
631187e0d8 | ||
|
|
92d1a4d367 | ||
|
|
f4123f4ae1 | ||
|
|
d4c2332c59 | ||
|
|
e257fc89c1 | ||
|
|
33aa1efc90 |
+1
-1
@@ -5,4 +5,4 @@
|
|||||||
/man/*.markdown
|
/man/*.markdown
|
||||||
/pkg
|
/pkg
|
||||||
/tags
|
/tags
|
||||||
|
/vendor
|
||||||
@@ -2,6 +2,10 @@ source "http://rubygems.org"
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
platform :jruby do
|
||||||
|
gem "posix-spawn", "~> 0.3.6"
|
||||||
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'parka'
|
gem 'parka'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
|
|||||||
+8
-3
@@ -1,8 +1,8 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.34.0)
|
foreman (0.37.0.pre2)
|
||||||
term-ansicolor (~> 1.0.5)
|
term-ansicolor (~> 1.0.7)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
@@ -17,14 +17,17 @@ GEM
|
|||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
fakefs (0.3.2)
|
fakefs (0.3.2)
|
||||||
hpricot (0.8.2)
|
hpricot (0.8.2)
|
||||||
|
hpricot (0.8.2-java)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
mustache (0.11.2)
|
mustache (0.11.2)
|
||||||
parka (0.6.2)
|
parka (0.6.2)
|
||||||
crack
|
crack
|
||||||
rest-client
|
rest-client
|
||||||
thor
|
thor
|
||||||
rake (0.9.2)
|
posix-spawn (0.3.6)
|
||||||
|
rake (0.9.2.2)
|
||||||
rcov (0.9.8)
|
rcov (0.9.8)
|
||||||
|
rcov (0.9.8-java)
|
||||||
rdiscount (1.6.5)
|
rdiscount (1.6.5)
|
||||||
rest-client (1.6.1)
|
rest-client (1.6.1)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
@@ -47,6 +50,7 @@ GEM
|
|||||||
xml-simple (1.0.15)
|
xml-simple (1.0.15)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
|
java
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
@@ -54,6 +58,7 @@ DEPENDENCIES
|
|||||||
fakefs (~> 0.3.2)
|
fakefs (~> 0.3.2)
|
||||||
foreman!
|
foreman!
|
||||||
parka
|
parka
|
||||||
|
posix-spawn (~> 0.3.6)
|
||||||
rake
|
rake
|
||||||
rcov (~> 0.9.8)
|
rcov (~> 0.9.8)
|
||||||
ronn
|
ronn
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
require "rubygems"
|
|
||||||
require "bundler"
|
|
||||||
Bundler.setup
|
|
||||||
|
|
||||||
require "rake"
|
require "rake"
|
||||||
require "rspec"
|
require "rspec"
|
||||||
require "rspec/core/rake_task"
|
require "rspec/core/rake_task"
|
||||||
@@ -102,9 +98,13 @@ def clean(file)
|
|||||||
rm file if File.exists?(file)
|
rm file if File.exists?(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def distribution_files
|
def distribution_files(type=nil)
|
||||||
require "foreman/distribution"
|
require "foreman/distribution"
|
||||||
Foreman::Distribution.files
|
base_files = Foreman::Distribution.files
|
||||||
|
type_files = type ?
|
||||||
|
Dir[File.expand_path("../dist/resources/#{type}/**/*", __FILE__)] :
|
||||||
|
[]
|
||||||
|
base_files.concat(type_files)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mkchdir(dir)
|
def mkchdir(dir)
|
||||||
|
|||||||
+35
-1
@@ -1,2 +1,36 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec $1 2>&1
|
#
|
||||||
|
#/ Usage: runner [-d <dir>] <command>
|
||||||
|
#/
|
||||||
|
#/ Run a command with exec, optionally changing directory first
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo $@ >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat $0 | grep '^#/' | cut -c4-
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":hd:" OPT; do
|
||||||
|
case $OPT in
|
||||||
|
d) cd $OPTARG ;;
|
||||||
|
h) usage ;;
|
||||||
|
\?) error "invalid option: -$OPTARG" ;;
|
||||||
|
:) error "option -$OPTARG requires an argument" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
command=$1
|
||||||
|
|
||||||
|
if [ "$1" == "" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec $1
|
||||||
|
|||||||
Vendored
+48
@@ -0,0 +1,48 @@
|
|||||||
|
file pkg("/apt-#{version}/foreman-#{version}.deb") => distribution_files("deb") do |t|
|
||||||
|
mkchdir(File.dirname(t.name)) do
|
||||||
|
mkchdir("usr/local/foreman") do
|
||||||
|
assemble_distribution
|
||||||
|
assemble_gems
|
||||||
|
assemble resource("deb/foreman"), "bin/foreman", 0755
|
||||||
|
File.chmod 0755, "bin/runner"
|
||||||
|
end
|
||||||
|
|
||||||
|
assemble resource("deb/control"), "control"
|
||||||
|
assemble resource("deb/postinst"), "postinst"
|
||||||
|
|
||||||
|
sh "tar czvf data.tar.gz usr/local/foreman --owner=root --group=root"
|
||||||
|
sh "tar czvf control.tar.gz control postinst"
|
||||||
|
|
||||||
|
File.open("debian-binary", "w") do |f|
|
||||||
|
f.puts "2.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
deb = File.basename(t.name)
|
||||||
|
|
||||||
|
sh "ar -r #{t.name} debian-binary control.tar.gz data.tar.gz"
|
||||||
|
|
||||||
|
touch "Sources"
|
||||||
|
sh "apt-ftparchive packages . > Packages"
|
||||||
|
sh "gzip -c Packages > Packages.gz"
|
||||||
|
sh "apt-ftparchive release . > Release"
|
||||||
|
sh "gpg -abs -u 0F1B0520 -o Release.gpg Release"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Build a .deb package"
|
||||||
|
task "deb:build" => pkg("/apt-#{version}/foreman-#{version}.deb")
|
||||||
|
|
||||||
|
desc "Remove build artifacts for .deb"
|
||||||
|
task "deb:clean" do
|
||||||
|
clean pkg("foreman-#{version}.deb")
|
||||||
|
FileUtils.rm_rf("pkg/apt-#{version}") if Dir.exists?("pkg/apt-#{version}")
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Publish .deb to S3."
|
||||||
|
task "deb:release" => "deb:build" do |t|
|
||||||
|
Dir["pkg/apt-#{version}/*"].each do |file|
|
||||||
|
unless File.directory?(file)
|
||||||
|
store file, "apt/#{File.basename(file)}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
file pkg("foreman-#{version}-jruby.gem") => distribution_files do |t|
|
||||||
|
sh "env PLATFORM=jruby gem build foreman.gemspec"
|
||||||
|
sh "mv foreman-#{version}-java.gem #{t.name}"
|
||||||
|
end
|
||||||
|
|
||||||
|
task "jruby:build" => pkg("foreman-#{version}-jruby.gem")
|
||||||
|
|
||||||
|
task "jruby:clean" do
|
||||||
|
clean pkg("foreman-#{version}-jruby.gem")
|
||||||
|
end
|
||||||
|
|
||||||
|
task "jruby:release" => "jruby:build" do |t|
|
||||||
|
sh "parka push -f #{pkg("foreman-#{version}-jruby.gem")}"
|
||||||
|
end
|
||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
Package: foreman
|
||||||
|
Version: <%= version %>
|
||||||
|
Section: main
|
||||||
|
Priority: standard
|
||||||
|
Architecture: all
|
||||||
|
Depends: ruby1.9.1
|
||||||
|
Maintainer: Heroku
|
||||||
|
Description: Manage Procfile-based applications.
|
||||||
|
Foreman is a manager for Procfile-based applications. Its aim is to
|
||||||
|
abstract away the details of the Procfile format, and allow you to
|
||||||
|
either run your application directly or export it to some other
|
||||||
|
process management format.
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env ruby1.9.1
|
||||||
|
|
||||||
|
# resolve bin path, ignoring symlinks
|
||||||
|
require "pathname"
|
||||||
|
bin_file = Pathname.new(__FILE__).realpath
|
||||||
|
|
||||||
|
# add locally vendored gems to libpath
|
||||||
|
gem_dir = File.expand_path("../../vendor/gems", bin_file)
|
||||||
|
Dir["#{gem_dir}/**/lib"].each do |libdir|
|
||||||
|
$:.unshift libdir
|
||||||
|
end
|
||||||
|
|
||||||
|
# add self to libpath
|
||||||
|
$:.unshift File.expand_path("../../lib", bin_file)
|
||||||
|
|
||||||
|
require "foreman/cli"
|
||||||
|
|
||||||
|
Foreman::CLI.start
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1.4.11 (Darwin)
|
||||||
|
|
||||||
|
mQENBE5SfAEBCADLp056ZgfdtAMXLWpEuL9zY+dIHIY5qLQcDmUivjHLVE4l3Bi3
|
||||||
|
Mn570K0W9rfk7fHBPEO2XJEDdjk8Bg6mWTAeGjdfZgZaL+qO9NjqQ5QmVR+vgp7s
|
||||||
|
yxJYlfY+JYTZvl/JiDWGhuPHSPggXILCMf3SpqWMHGPqe/3RAK+CHCNv/94uaoS4
|
||||||
|
vi4HQT+k4sRceiM8WqkSRYSoc7rzdDejZn+InCYFfR56VeSFF4G4I6neZs/q5T9d
|
||||||
|
Ty2i5d0gZLaX/Iqc+3Dy0vDKClc0HUQJ6ajDPuUqKLHFUpqyuwfJij60+C3GMi8K
|
||||||
|
ckRPti31EPFVzq3GPHU+GqA+e9j84WHr4uJ5ABEBAAG0L0hlcm9rdSBSZWxlYXNl
|
||||||
|
IEVuZ2luZWVyaW5nIDxyZWxlYXNlQGhlcm9rdS5jb20+iQE4BBMBAgAiBQJOUnwB
|
||||||
|
AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDJJ+vgDxsFIChECAC9h4Ay
|
||||||
|
Nx4AQFu85cjR9rijyBflPeVqi7Xhzd7IvLg2+kZSexlb2oidj7iVSMy+vy5tG9g9
|
||||||
|
8Az/JqMCVjcZ7ltn60OGU8gIYpJqt6VmH3vfJBxXu/Sm9tym3UCYGVvMAN5Oq6yB
|
||||||
|
HlQkQ8F3p0cW69PmF+fibkgo9RE0EYlBIt2rUHNilTGFS6vXGr5reFFp3/rRHq3k
|
||||||
|
bixnUwFSqNujJgnBKDPwtSYKc4pMpnhuv88xEpLH7vU8NLXQZMitKQguV8XEmcsu
|
||||||
|
43LXlsx5uVr239/XNW+h412gIHFDSzB/YuLWlVUXMfquC96z/wxMqWWZyskDNgr0
|
||||||
|
WDdMgzK6CUfXSqQhuQENBE5SfAEBCADbnGKcXpdVauQpINQLtRnrT0BJIrIo1Yxv
|
||||||
|
LQRb3G7RU+Eq6aHXwk9fSKa6nEv9RsmqiW874yODnr0d/DTUWMHT+jRvPHm1wlbE
|
||||||
|
pGR1aPSo7GgkSUdaT6CVBN3JWZ2kVJGqohNoJMYbfVaWd/kpa/LiMFWzS8LfWT2K
|
||||||
|
xiO2vIh4qBfeRCGR7s8rADCHuHJ0eibADrgqcRfdPrChB1JiYLeTdV4yRmSzJ7TM
|
||||||
|
zWX7OVpGfIFLbCw9NeN65pI9ePs2mSPM7DYkhhKSXWMwJNXFzn1blOGiwAwKb48P
|
||||||
|
a/QpE6TG3PQzbYyTTP0Td1XgKAHcprvbc89a/nAk3a+PJQ/MqvDzABEBAAGJAR8E
|
||||||
|
GAECAAkFAk5SfAECGwwACgkQySfr4A8bBSD4mAgAnCT5WRiDl0259Px9Z9J9Wk8Z
|
||||||
|
SxugDct2Yhzca4aw1Ou4cfaIFCDXzFlBzSJfqk0HoVhp9r2gzEPUCKnSjRDyxaMo
|
||||||
|
wZCUtqigBua+z4NB4AWgeOl/2S06I2ki1K7pfl4piYcHtEThHamnhVPJ2Hi6HsHq
|
||||||
|
mUU+8SxleHE4GCXmKkuvxelUq9jrhHikIkm1RoqFOPb9zV3WRy4YzVHQSYfHmfk0
|
||||||
|
9kXlM/CS0sfNv2UKCX+5e6eFIZv0rdtpp6VEh0tsFmsIClY6Z9MX7bgp8MnUJpyk
|
||||||
|
OeIzOzQgkb4aeT0Whl+EPcTeDZfqIhVBoNXupUanmWNppFcMngxfqG2NGi1vvQ==
|
||||||
|
=aUAq
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
ln -sf /usr/local/foreman/bin/foreman /usr/bin/foreman
|
||||||
+6
-1
@@ -16,6 +16,11 @@ 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.5'
|
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"] == "jruby"
|
||||||
|
gem.add_dependency "posix-spawn", "~> 0.3.6"
|
||||||
|
gem.platform = Gem::Platform.new("java")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+6
-4
@@ -5,7 +5,9 @@ require "thor"
|
|||||||
require "yaml"
|
require "yaml"
|
||||||
|
|
||||||
class Foreman::CLI < Thor
|
class Foreman::CLI < Thor
|
||||||
|
|
||||||
|
desc "start", "Start the application"
|
||||||
|
|
||||||
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile"
|
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile"
|
||||||
class_option :app_root, :type => :string, :aliases => "-d", :desc => "Default: Procfile directory"
|
class_option :app_root, :type => :string, :aliases => "-d", :desc => "Default: Procfile directory"
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ class Foreman::CLI < Thor
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
check_procfile!
|
check_procfile!
|
||||||
engine.start
|
engine.start
|
||||||
@@ -60,7 +62,7 @@ class Foreman::CLI < Thor
|
|||||||
error "no processes defined" unless engine.procfile.entries.length > 0
|
error "no processes defined" unless engine.procfile.entries.length > 0
|
||||||
display "valid procfile detected (#{engine.procfile.process_names.join(', ')})"
|
display "valid procfile detected (#{engine.procfile.process_names.join(', ')})"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "run COMMAND", "Run a command using your application's environment"
|
desc "run COMMAND", "Run a command using your application's environment"
|
||||||
|
|
||||||
def run(*args)
|
def run(*args)
|
||||||
@@ -73,7 +75,7 @@ class Foreman::CLI < Thor
|
|||||||
error "command not found: #{args.first}"
|
error "command not found: #{args.first}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private ######################################################################
|
private ######################################################################
|
||||||
|
|
||||||
def check_procfile!
|
def check_procfile!
|
||||||
|
|||||||
+25
-12
@@ -1,4 +1,5 @@
|
|||||||
require "foreman"
|
require "foreman"
|
||||||
|
require "rubygems"
|
||||||
|
|
||||||
class Foreman::Process
|
class Foreman::Process
|
||||||
|
|
||||||
@@ -14,10 +15,8 @@ class Foreman::Process
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run(pipe, basedir, environment)
|
def run(pipe, basedir, environment)
|
||||||
Dir.chdir(basedir) do
|
with_environment(environment.merge("PORT" => port.to_s)) do
|
||||||
with_environment(environment.merge("PORT" => port.to_s)) do
|
run_process basedir, entry.command, pipe
|
||||||
run_process entry.command, pipe
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,19 +26,33 @@ class Foreman::Process
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def fork_with_io(command)
|
def jruby?
|
||||||
|
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
|
||||||
|
end
|
||||||
|
|
||||||
|
def fork_with_io(command, basedir)
|
||||||
reader, writer = IO.pipe
|
reader, writer = IO.pipe
|
||||||
pid = fork do
|
command = replace_command_env(command)
|
||||||
trap("INT", "IGNORE")
|
pid = if jruby?
|
||||||
$stdout.reopen writer
|
require "posix/spawn"
|
||||||
reader.close
|
POSIX::Spawn.spawn(Foreman.runner, "-d", basedir, command, {
|
||||||
exec Foreman.runner, replace_command_env(command)
|
:out => writer, :err => writer
|
||||||
|
})
|
||||||
|
else
|
||||||
|
fork do
|
||||||
|
trap("INT", "IGNORE")
|
||||||
|
writer.sync = true
|
||||||
|
$stdout.reopen writer
|
||||||
|
$stderr.reopen writer
|
||||||
|
reader.close
|
||||||
|
exec Foreman.runner, "-d", basedir, command
|
||||||
|
end
|
||||||
end
|
end
|
||||||
[ reader, pid ]
|
[ reader, pid ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_process(command, pipe)
|
def run_process(basedir, command, pipe)
|
||||||
io, @pid = fork_with_io(command)
|
io, @pid = fork_with_io(command, basedir)
|
||||||
output pipe, "started with pid %d" % @pid
|
output pipe, "started with pid %d" % @pid
|
||||||
Thread.new do
|
Thread.new do
|
||||||
until io.eof?
|
until io.eof?
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ class Foreman::Utils
|
|||||||
def self.parse_concurrency(concurrency)
|
def self.parse_concurrency(concurrency)
|
||||||
begin
|
begin
|
||||||
pairs = concurrency.to_s.gsub(/\s/, "").split(",")
|
pairs = concurrency.to_s.gsub(/\s/, "").split(",")
|
||||||
pairs.inject(Hash.new(1)) do |hash, pair|
|
|
||||||
|
default = concurrency.nil? ? 1 : 0
|
||||||
|
|
||||||
|
pairs.inject(Hash.new(default)) do |hash, pair|
|
||||||
process, amount = pair.split("=")
|
process, amount = pair.split("=")
|
||||||
hash.update(process => amount.to_i)
|
hash.update(process => amount.to_i)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Foreman
|
module Foreman
|
||||||
|
|
||||||
VERSION = "0.34.0"
|
VERSION = "0.37.0.pre2"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ describe "Foreman::Engine" do
|
|||||||
write_procfile
|
write_procfile
|
||||||
engine = Foreman::Engine.new("Procfile",:concurrency => "alpha=2")
|
engine = Foreman::Engine.new("Procfile",:concurrency => "alpha=2")
|
||||||
mock.instance_of(Foreman::Process).run_process("./alpha", is_a(IO)).twice
|
mock.instance_of(Foreman::Process).run_process("./alpha", is_a(IO)).twice
|
||||||
mock.instance_of(Foreman::Process).run_process("./bravo", is_a(IO))
|
mock.instance_of(Foreman::Process).run_process("./bravo", is_a(IO)).never
|
||||||
mock(engine).watch_for_output
|
mock(engine).watch_for_output
|
||||||
mock(engine).watch_for_termination
|
mock(engine).watch_for_termination
|
||||||
engine.start
|
engine.start
|
||||||
|
|||||||
@@ -12,8 +12,13 @@ describe Foreman::Export::Bluepill do
|
|||||||
before(:each) { stub(bluepill).say }
|
before(:each) { stub(bluepill).say }
|
||||||
|
|
||||||
it "exports to the filesystem" do
|
it "exports to the filesystem" do
|
||||||
bluepill.export("/tmp/init", :concurrency => "alpha=2")
|
bluepill.export("/tmp/init")
|
||||||
File.read("/tmp/init/app.pill").should == example_export_file("bluepill/app.pill")
|
normalize_space(File.read("/tmp/init/app.pill")).should == normalize_space(example_export_file("bluepill/app.pill"))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
it "exports to the filesystem with concurrency" do
|
||||||
|
bluepill.export("/tmp/init", :concurrency => "alpha=2")
|
||||||
|
|
||||||
|
normalize_space(File.read("/tmp/init/app.pill")).should == normalize_space(example_export_file("bluepill/app-concurrency.pill"))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -14,7 +14,7 @@ describe Foreman::Export::Runit do
|
|||||||
|
|
||||||
it "exports to the filesystem" do
|
it "exports to the filesystem" do
|
||||||
FileUtils.mkdir_p('/tmp/init')
|
FileUtils.mkdir_p('/tmp/init')
|
||||||
runit.export('/tmp/init', :concurrency => 'alpha=2')
|
runit.export('/tmp/init', :concurrency => "alpha=2,bravo=1")
|
||||||
|
|
||||||
File.read("/tmp/init/app-alpha-1/run").should == example_export_file('runit/app-alpha-1-run')
|
File.read("/tmp/init/app-alpha-1/run").should == example_export_file('runit/app-alpha-1-run')
|
||||||
File.read("/tmp/init/app-alpha-1/log/run").should ==
|
File.read("/tmp/init/app-alpha-1/log/run").should ==
|
||||||
|
|||||||
@@ -12,14 +12,23 @@ describe Foreman::Export::Upstart do
|
|||||||
before(:each) { stub(upstart).say }
|
before(:each) { stub(upstart).say }
|
||||||
|
|
||||||
it "exports to the filesystem" do
|
it "exports to the filesystem" do
|
||||||
|
upstart.export("/tmp/init")
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == example_export_file("upstart/app.conf")
|
||||||
|
File.read("/tmp/init/app-alpha.conf").should == example_export_file("upstart/app-alpha.conf")
|
||||||
|
File.read("/tmp/init/app-alpha-1.conf").should == example_export_file("upstart/app-alpha-1.conf")
|
||||||
|
File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf")
|
||||||
|
File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "exports to the filesystem with concurrency" do
|
||||||
upstart.export("/tmp/init", :concurrency => "alpha=2")
|
upstart.export("/tmp/init", :concurrency => "alpha=2")
|
||||||
|
|
||||||
File.read("/tmp/init/app.conf").should == example_export_file("upstart/app.conf")
|
File.read("/tmp/init/app.conf").should == example_export_file("upstart/app.conf")
|
||||||
File.read("/tmp/init/app-alpha.conf").should == example_export_file("upstart/app-alpha.conf")
|
File.read("/tmp/init/app-alpha.conf").should == example_export_file("upstart/app-alpha.conf")
|
||||||
File.read("/tmp/init/app-alpha-1.conf").should == example_export_file("upstart/app-alpha-1.conf")
|
File.read("/tmp/init/app-alpha-1.conf").should == example_export_file("upstart/app-alpha-1.conf")
|
||||||
File.read("/tmp/init/app-alpha-2.conf").should == example_export_file("upstart/app-alpha-2.conf")
|
File.read("/tmp/init/app-alpha-2.conf").should == example_export_file("upstart/app-alpha-2.conf")
|
||||||
File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf")
|
File.exists?("/tmp/init/app-bravo-1.conf").should == false
|
||||||
File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with alternate templates" do
|
context "with alternate templates" do
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepill.log") do |app|
|
||||||
|
|
||||||
|
app.uid = "app"
|
||||||
|
app.gid = "app"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app.process("alpha-1") do |process|
|
||||||
|
process.start_command = "./alpha"
|
||||||
|
|
||||||
|
process.working_dir = "/tmp/app"
|
||||||
|
process.daemonize = true
|
||||||
|
process.environment = {"PORT" => "5000"}
|
||||||
|
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
|
||||||
|
|
||||||
|
process.stdout = process.stderr = "/var/log/app/app-alpha-1.log"
|
||||||
|
|
||||||
|
process.monitor_children do |children|
|
||||||
|
children.stop_command "kill -QUIT {{PID}}"
|
||||||
|
end
|
||||||
|
|
||||||
|
process.group = "app-alpha"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
app.process("alpha-2") do |process|
|
||||||
|
process.start_command = "./alpha"
|
||||||
|
|
||||||
|
process.working_dir = "/tmp/app"
|
||||||
|
process.daemonize = true
|
||||||
|
process.environment = {"PORT" => "5001"}
|
||||||
|
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
|
||||||
|
|
||||||
|
process.stdout = process.stderr = "/var/log/app/app-alpha-2.log"
|
||||||
|
|
||||||
|
process.monitor_children do |children|
|
||||||
|
children.stop_command "kill -QUIT {{PID}}"
|
||||||
|
end
|
||||||
|
|
||||||
|
process.group = "app-alpha"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
@@ -23,27 +23,6 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil
|
|||||||
process.group = "app-alpha"
|
process.group = "app-alpha"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
app.process("alpha-2") do |process|
|
|
||||||
process.start_command = "./alpha"
|
|
||||||
|
|
||||||
process.working_dir = "/tmp/app"
|
|
||||||
process.daemonize = true
|
|
||||||
process.environment = {"PORT" => "5001"}
|
|
||||||
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
|
|
||||||
|
|
||||||
process.stdout = process.stderr = "/var/log/app/app-alpha-2.log"
|
|
||||||
|
|
||||||
process.monitor_children do |children|
|
|
||||||
children.stop_command "kill -QUIT {{PID}}"
|
|
||||||
end
|
|
||||||
|
|
||||||
process.group = "app-alpha"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.process("bravo-1") do |process|
|
app.process("bravo-1") do |process|
|
||||||
process.start_command = "./bravo"
|
process.start_command = "./bravo"
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ def preserving_env
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize_space(s)
|
||||||
|
s.gsub(/\n[\n\s]*/, "\n")
|
||||||
|
end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.color_enabled = true
|
config.color_enabled = true
|
||||||
config.order = 'rand'
|
config.order = 'rand'
|
||||||
|
|||||||
Reference in New Issue
Block a user