Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a73dce5405 | ||
|
|
2abddb42b3 | ||
|
|
d961a32cfe | ||
|
|
2bfc065c1d | ||
|
|
fbe3d4ec69 | ||
|
|
631187e0d8 | ||
|
|
92d1a4d367 | ||
|
|
f4123f4ae1 | ||
|
|
d4c2332c59 | ||
|
|
e257fc89c1 | ||
|
|
33aa1efc90 |
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.34.0)
|
foreman (0.36.0)
|
||||||
term-ansicolor (~> 1.0.5)
|
term-ansicolor (~> 1.0.5)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ GEM
|
|||||||
crack
|
crack
|
||||||
rest-client
|
rest-client
|
||||||
thor
|
thor
|
||||||
rake (0.9.2)
|
rake (0.9.2.2)
|
||||||
rcov (0.9.8)
|
rcov (0.9.8)
|
||||||
rdiscount (1.6.5)
|
rdiscount (1.6.5)
|
||||||
rest-client (1.6.1)
|
rest-client (1.6.1)
|
||||||
|
|||||||
+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!
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ private
|
|||||||
reader, writer = IO.pipe
|
reader, writer = IO.pipe
|
||||||
pid = fork do
|
pid = fork do
|
||||||
trap("INT", "IGNORE")
|
trap("INT", "IGNORE")
|
||||||
|
writer.sync = true
|
||||||
$stdout.reopen writer
|
$stdout.reopen writer
|
||||||
|
$stderr.reopen writer
|
||||||
reader.close
|
reader.close
|
||||||
exec Foreman.runner, replace_command_env(command)
|
exec Foreman.runner, replace_command_env(command)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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.36.0"
|
||||||
|
|
||||||
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