Compare commits

...

23 Commits

Author SHA1 Message Date
David Dollar
5f0f2f5378 0.53.0 2012-07-24 11:18:20 -04:00
David Dollar
c1b57b59cf put app root in $HOME 2012-07-24 11:18:05 -04:00
David Dollar
21d53818f2 add changelog 2012-07-24 11:11:04 -04:00
David Dollar
359d6f1c34 0.52.0 2012-07-24 11:10:16 -04:00
David Dollar
584f251e4a wrap command in a runner that sources .profile.d scripts 2012-07-24 11:09:54 -04:00
David Dollar
7d9c2b2ac4 fix upstart export specs 2012-07-24 10:50:34 -04:00
David Dollar
fba4d9beff Merge pull request #229 from danielfarrell/autostart-upstart
Make upstart export start/stop with network
2012-07-18 13:55:01 -07:00
Daniel Farrell
0bde5fdab5 Make upstart export start/stop with network 2012-07-18 16:50:49 -04:00
David Dollar
1beab80c1f update docs 2012-07-11 18:33:13 -04:00
David Dollar
7b270f9f4a changelog 2012-07-11 18:33:10 -04:00
David Dollar
03e5342067 0.51.0 2012-07-11 18:32:51 -04:00
David Dollar
b1d57426fb dont try to colorize windows 2012-07-11 18:30:51 -04:00
David Dollar
06e5c52f35 add mswin32 dist 2012-07-11 18:30:38 -04:00
David Dollar
64ca839c0b update docs 2012-07-11 16:17:13 -04:00
David Dollar
80aebda023 update changelog 2012-07-11 16:17:10 -04:00
David Dollar
5dee2281a2 fix up release tasks 2012-07-11 16:16:29 -04:00
David Dollar
efb6d2f11d 0.50.0 2012-07-11 16:07:52 -04:00
David Dollar
ac528d3b50 update docs 2012-07-11 16:07:03 -04:00
David Dollar
cefd4e351e handle windows 2012-07-11 16:02:07 -04:00
David Dollar
9849f4558a 0.49.0 2012-07-11 15:05:47 -04:00
David Dollar
4b53b42be1 1.8 compatibility 2012-07-11 15:05:28 -04:00
David Dollar
219acaf690 use one pgroup for all of foreman and kill that since ruby 1.8 sucks at pgroups 2012-07-11 15:05:20 -04:00
David Dollar
f8118d7b40 better debugging 2012-07-11 15:04:30 -04:00
15 changed files with 143 additions and 34 deletions

View File

@@ -1,8 +1,46 @@
## 0.48.0.pre1 (2012-06-11)
## 0.52.0 (2012-07-24)
* Massive refactoring for programmatic control and stability [David Dollar]
* Procfile commands with shell interpolations now work again [David Dollar]
* Stop trying to test on Ruby 1.8 [David Dollar]
* wrap command in a runner that sources .profile.d scripts [David Dollar]
* fix upstart export specs [David Dollar]
* Make upstart export start/stop with network [Daniel Farrell]
## 0.51.0 (2012-07-11)
* dont try to colorize windows [David Dollar]
## 0.50.0 (2012-07-11)
* handle windows [David Dollar]
## 0.49.0 (2012-07-11)
* 1.8 compatibility [David Dollar]
* use one pgroup for all of foreman and kill that since ruby 1.8 sucks at pgroups [David Dollar]
* better debugging [David Dollar]
## 0.48.0 (2012-07-10)
* allow old exporter format to work, but with deprecation warning [David Dollar]
* remove debugging code [David Dollar]
* Merge pull request #219 from MarkDBlackwell/patch-1 [David Dollar]
* Avoid crash by verifying the existence of SIGHUP before accessing it. [Mark D. Blackwell]
* allow color to be forced on [David Dollar]
* terminate gracefully if stdout goes away [David Dollar]
* always flush output [David Dollar]
* Merge pull request #212 from morgoth/added-version-command [David Dollar]
* added command for displaying foreman version [Wojciech Wnętrzak]
* Merge pull request #211 from morgoth/fixed-yaml-usage [David Dollar]
* fixed using YAML [Wojciech Wnętrzak]
* test on more things, but don't fail [David Dollar]
* changelog [David Dollar]
* 0.48.0.pre1 [David Dollar]
* foreman doesn't work on ruby 1.8, may try to fix later [David Dollar]
* use bash [David Dollar]
* massive refactoring for programmatic control and stability [David Dollar]
* Merge pull request #164 from hsume2/master [David Dollar]
* Only run tmux specs if tmux is installed [Henry Hsu]
* Do not assume BUNDLE_GEMFILE [Henry Hsu]
* Add support for starting procfile in tmux session [Henry Hsu]
## 0.47.0 (2012-06-07)

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
foreman (0.48.0)
foreman (0.53.0)
thor (>= 0.13.6)
GEM
@@ -39,7 +39,7 @@ GEM
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
thor (0.15.3)
thor (0.15.4)
timecop (0.3.5)
win32console (1.3.0-x86-mingw32)
xml-simple (1.0.15)

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/bash
#
#/ Usage: foreman-runner [-d <dir>] <command> [<args>...]
#/ Usage: foreman-runner [-d <dir>] [-p] <command> [<args>...]
#/
#/ Run a command with exec, optionally changing directory first
@@ -16,9 +16,12 @@ usage() {
exit
}
while getopts ":hd:" OPT; do
read_profiled=""
while getopts ":hd:p" OPT; do
case $OPT in
d) cd "$OPTARG" ;;
p) read_profiled="1" ;;
h) usage ;;
\?) error "invalid option: -$OPTARG" ;;
:) error "option -$OPTARG requires an argument" ;;
@@ -29,4 +32,13 @@ shift $((OPTIND-1))
[ -z "$1" ] && usage
if [ "$read_profiled" == "1" ]; then
shopt -s nullglob
for script in .profile.d/*; do
echo "sourcing $script"
source $script
done
shopt -u nullglob
fi
exec "$@"

View File

@@ -0,0 +1,2 @@
#!/bin/sh
export FOO=bar

View File

@@ -9,6 +9,6 @@ sigterm() {
#trap sigterm SIGTERM
while true; do
echo "$NAME: ping"
echo "$NAME: ping $$"
sleep 1
done

View File

@@ -6,3 +6,6 @@ bash << "EOF"
EOF
end script
start on started network
stop on stopping network

16
dist/mswin32.rake vendored Normal file
View File

@@ -0,0 +1,16 @@
file pkg("foreman-#{version}-x86-mswin32.gem") => distribution_files do |t|
Bundler.with_clean_env do
sh "env PLATFORM=mswin32 gem build foreman.gemspec"
end
sh "mv foreman-#{version}-x86-mswin32.gem #{t.name}"
end
task "mswin32:build" => pkg("foreman-#{version}-x86-mswin32.gem")
task "mswin32:clean" do
clean pkg("foreman-#{version}-x86-mswin32.gem")
end
task "mswin32:release" => "mswin32:build" do |t|
sh "gem push #{pkg("foreman-#{version}-x86-mswin32.gem")} || echo 'error'"
end

View File

@@ -12,6 +12,10 @@ module Foreman
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
end
def self.ruby_18?
defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
end
def self.windows?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
end

View File

@@ -99,10 +99,17 @@ class Foreman::Engine
# @param [String] signal The signal to send to each process
#
def killall(signal="SIGTERM")
@running.each do |pid, (process, index)|
system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
if Foreman.windows?
@running.each do |pid, (process, index)|
system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
begin
Process.kill(signal, pid)
rescue Errno::ESRCH, Errno::EPERM
end
end
else
begin
Process.kill(signal, -1 * pid)
Process.kill "-#{signal}", Process.pid
rescue Errno::ESRCH, Errno::EPERM
end
end
@@ -249,7 +256,10 @@ private
1.upto(formation[@names[process]]) do |n|
reader, writer = create_pipe
begin
pid = process.run(:output => writer, :env => { "PORT" => port_for(process, n).to_s })
pid = process.run(:output => writer, :env => {
"HOME" => process.cwd,
"PORT" => port_for(process, n).to_s
})
writer.puts "started with pid #{pid}"
rescue Errno::ENOENT
writer.puts "unknown command: #{process.command}"
@@ -266,7 +276,7 @@ private
loop do
(IO.select(@readers.values).first || []).each do |reader|
data = reader.gets
output_with_mutex name_for(@readers.key(reader)), data
output_with_mutex name_for(@readers.invert[reader]), data
end
end
rescue Exception => ex
@@ -288,8 +298,13 @@ private
def terminate_gracefully
return if @terminating
@terminating = true
system "sending SIGTERM to all processes"
killall "SIGTERM"
if Foreman.windows?
system "sending SIGKILL to all processes"
killall "SIGKILL"
else
system "sending SIGTERM to all processes"
killall "SIGTERM"
end
Timeout.timeout(5) do
watch_for_termination while @running.length > 0
end

View File

@@ -31,6 +31,7 @@ class Foreman::Engine::CLI < Foreman::Engine
def color?
return true if @@color_force
return false if Foreman.windows?
return false unless self.respond_to?(:isatty)
self.isatty && ENV["TERM"]
end
@@ -48,12 +49,12 @@ class Foreman::Engine::CLI < Foreman::Engine
def startup
@colors = map_colors
proctitle "foreman: master"
proctitle "foreman: master" unless Foreman.windows?
Color.enable($stdout, options[:color])
end
def output(name, data)
data.to_s.chomp.split("\n").each do |message|
Color.enable($stdout, options[:color]) unless $stdout.respond_to?(:color?)
output = ""
output += $stdout.color(@colors[name.split(".").first].to_sym)
output += "#{Time.now.strftime("%H:%M:%S")} #{pad_process_name(name)} | "

View File

@@ -36,17 +36,27 @@ class Foreman::Process
if Foreman.windows?
Dir.chdir(cwd) do
Process.spawn env, command, :out => output, :err => output, :new_pgroup => true
expanded_command = command.dup
env.each do |key, val|
expanded_command.gsub!("$#{key}", val)
end
Process.spawn env, expanded_command, :out => output, :err => output
end
elsif Foreman.jruby?
Dir.chdir(cwd) do
require "posix/spawn"
POSIX::Spawn.spawn env, command, :out => output, :err => output, :pgroup => 0
require "posix/spawn"
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
POSIX::Spawn.spawn env, wrapped_command, :out => output, :err => output
elsif Foreman.ruby_18?
fork do
$stdout.reopen output
$stderr.reopen output
env.each { |k,v| ENV[k] = v }
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
exec wrapped_command
end
else
Dir.chdir(cwd) do
Process.spawn env, command, :out => output, :err => output, :pgroup => 0
end
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
Process.spawn env, wrapped_command, :out => output, :err => output
end
end
@@ -55,7 +65,11 @@ class Foreman::Process
# @param [String] signal The signal to send
#
def kill(signal)
pid && Process.kill(signal, -1 * pid)
if Foreman.windows?
pid && Process.kill(signal, pid)
else
pid && Process.kill("-#{signal}", pid)
end
rescue Errno::ESRCH
false
end
@@ -76,10 +90,12 @@ class Foreman::Process
!alive?
end
private
# Returns the working directory for this +Process+
#
# @returns [String]
#
def cwd
@options[:cwd] || "."
File.expand_path(@options[:cwd] || ".")
end
end

View File

@@ -1,5 +1,5 @@
module Foreman
VERSION = "0.48.0"
VERSION = "0.53.0"
end

View File

@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "FOREMAN" "1" "April 2012" "Foreman 0.46.0" "Foreman Manual"
.TH "FOREMAN" "1" "July 2012" "Foreman 0.51.0" "Foreman Manual"
.
.SH "NAME"
\fBforeman\fR \- manage Procfile\-based applications

View File

@@ -6,3 +6,6 @@ bash << "EOF"
EOF
end script
start on started network
stop on stopping network

View File

@@ -32,7 +32,7 @@ def latest_release
end
def newer_release
tags = %x{ git tag --contains v#{latest_release} }.split("\n").sort_by do |tag|
tags = %x{ git tag --contains v#{latest_release} | grep -v pre }.split("\n").sort_by do |tag|
Gem::Version.new(tag[1..-1])
end
tags[1]
@@ -60,7 +60,6 @@ end
desc "Cut a release"
task :release do
Rake::Task["authors"].invoke
Rake::Task["changelog"].invoke
Rake::Task["pages"].invoke
end