foreman 0.59.0 → 0.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/foreman/cli.rb +10 -1
- data/lib/foreman/engine.rb +2 -1
- data/lib/foreman/process.rb +32 -7
- data/lib/foreman/version.rb +1 -1
- data/man/foreman.1 +1 -1
- data/spec/foreman/cli_spec.rb +4 -0
- metadata +4 -4
data/lib/foreman/cli.rb
CHANGED
|
@@ -75,10 +75,19 @@ class Foreman::CLI < Thor
|
|
|
75
75
|
|
|
76
76
|
def run(*args)
|
|
77
77
|
load_environment!
|
|
78
|
+
|
|
79
|
+
if File.exist?(procfile)
|
|
80
|
+
engine.load_procfile(procfile)
|
|
81
|
+
end
|
|
82
|
+
|
|
78
83
|
pid = fork do
|
|
79
84
|
begin
|
|
80
85
|
engine.env.each { |k,v| ENV[k] = v }
|
|
81
|
-
|
|
86
|
+
if args.size == 1 && process = engine.process(args.first)
|
|
87
|
+
process.exec(:env => engine.env)
|
|
88
|
+
else
|
|
89
|
+
exec args.shelljoin
|
|
90
|
+
end
|
|
82
91
|
rescue Errno::EACCES
|
|
83
92
|
error "not executable: #{args.first}"
|
|
84
93
|
rescue Errno::ENOENT
|
data/lib/foreman/engine.rb
CHANGED
|
@@ -273,7 +273,8 @@ private
|
|
|
273
273
|
Thread.new do
|
|
274
274
|
begin
|
|
275
275
|
loop do
|
|
276
|
-
|
|
276
|
+
io = IO.select(@readers.values, nil, nil, 30)
|
|
277
|
+
(io.nil? ? [] : io.first).each do |reader|
|
|
277
278
|
data = reader.gets
|
|
278
279
|
output_with_mutex name_for(@readers.invert[reader]), data
|
|
279
280
|
end
|
data/lib/foreman/process.rb
CHANGED
|
@@ -21,6 +21,21 @@ class Foreman::Process
|
|
|
21
21
|
@options[:env] ||= {}
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
# Get environment-expanded command for a +Process+
|
|
25
|
+
#
|
|
26
|
+
# @param [Hash] custom_env ({}) Environment variables to merge with defaults
|
|
27
|
+
#
|
|
28
|
+
# @return [String] The expanded command
|
|
29
|
+
#
|
|
30
|
+
def expanded_command(custom_env={})
|
|
31
|
+
env = @options[:env].merge(custom_env)
|
|
32
|
+
expanded_command = command.dup
|
|
33
|
+
env.each do |key, val|
|
|
34
|
+
expanded_command.gsub!("$#{key}", val)
|
|
35
|
+
end
|
|
36
|
+
expanded_command
|
|
37
|
+
end
|
|
38
|
+
|
|
24
39
|
# Run a +Process+
|
|
25
40
|
#
|
|
26
41
|
# @param [Hash] options
|
|
@@ -31,16 +46,12 @@ class Foreman::Process
|
|
|
31
46
|
# @returns [Fixnum] pid The +pid+ of the process
|
|
32
47
|
#
|
|
33
48
|
def run(options={})
|
|
34
|
-
env =
|
|
49
|
+
env = @options[:env].merge(options[:env] || {})
|
|
35
50
|
output = options[:output] || $stdout
|
|
36
51
|
|
|
37
52
|
if Foreman.windows?
|
|
38
53
|
Dir.chdir(cwd) do
|
|
39
|
-
expanded_command
|
|
40
|
-
env.each do |key, val|
|
|
41
|
-
expanded_command.gsub!("$#{key}", val)
|
|
42
|
-
end
|
|
43
|
-
Process.spawn env, expanded_command, :out => output, :err => output
|
|
54
|
+
Process.spawn env, expanded_command(env), :out => output, :err => output
|
|
44
55
|
end
|
|
45
56
|
elsif Foreman.jruby?
|
|
46
57
|
require "posix/spawn"
|
|
@@ -52,7 +63,7 @@ class Foreman::Process
|
|
|
52
63
|
$stderr.reopen output
|
|
53
64
|
env.each { |k,v| ENV[k] = v }
|
|
54
65
|
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
|
|
55
|
-
exec wrapped_command
|
|
66
|
+
Kernel.exec wrapped_command
|
|
56
67
|
end
|
|
57
68
|
else
|
|
58
69
|
wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
|
|
@@ -60,6 +71,20 @@ class Foreman::Process
|
|
|
60
71
|
end
|
|
61
72
|
end
|
|
62
73
|
|
|
74
|
+
# Exec a +Process+
|
|
75
|
+
#
|
|
76
|
+
# @param [Hash] options
|
|
77
|
+
#
|
|
78
|
+
# @option options :env ({}) Environment variables to set for this execution
|
|
79
|
+
#
|
|
80
|
+
# @return Does not return
|
|
81
|
+
def exec(options={})
|
|
82
|
+
env = @options[:env].merge(options[:env] || {})
|
|
83
|
+
env.each { |k, v| ENV[k] = v }
|
|
84
|
+
Dir.chdir(cwd)
|
|
85
|
+
Kernel.exec expanded_command(env)
|
|
86
|
+
end
|
|
87
|
+
|
|
63
88
|
# Send a signal to this +Process+
|
|
64
89
|
#
|
|
65
90
|
# @param [String] signal The signal to send
|
data/lib/foreman/version.rb
CHANGED
data/man/foreman.1
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
|
3
3
|
.
|
|
4
|
-
.TH "FOREMAN" "1" "
|
|
4
|
+
.TH "FOREMAN" "1" "August 2012" "Foreman 0.60.1" "Foreman Manual"
|
|
5
5
|
.
|
|
6
6
|
.SH "NAME"
|
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
data/spec/foreman/cli_spec.rb
CHANGED
|
@@ -73,6 +73,10 @@ describe "Foreman::CLI", :fakefs do
|
|
|
73
73
|
forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
it "can run a command from the Procfile" do
|
|
77
|
+
forked_foreman("run -f #{resource_path("Procfile")} test").should == "testing\n"
|
|
78
|
+
end
|
|
79
|
+
|
|
76
80
|
it "exits with the same exit code as the command" do
|
|
77
81
|
fork_and_get_exitstatus("run echo 1").should == 0
|
|
78
82
|
fork_and_get_exitstatus("run date 'invalid_date'").should == 1
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.60.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-10-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: thor
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70307655459020 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,7 +21,7 @@ dependencies:
|
|
|
21
21
|
version: 0.13.6
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70307655459020
|
|
25
25
|
description: Process manager for applications with multiple components
|
|
26
26
|
email: ddollar@gmail.com
|
|
27
27
|
executables:
|