foreman 0.36.1 → 0.37.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/runner +34 -0
- data/lib/foreman/process.rb +25 -14
- data/lib/foreman/version.rb +1 -1
- metadata +10 -16
data/bin/runner
CHANGED
@@ -1,2 +1,36 @@
|
|
1
1
|
#!/bin/sh
|
2
|
+
#
|
3
|
+
#/ Usage: runner [-d <dir>] <command>
|
4
|
+
#/
|
5
|
+
#/ Run a command with exec, optionally changing directory first
|
6
|
+
|
7
|
+
set -e
|
8
|
+
|
9
|
+
error() {
|
10
|
+
echo $@ >&2
|
11
|
+
exit 1
|
12
|
+
}
|
13
|
+
|
14
|
+
usage() {
|
15
|
+
cat $0 | grep '^#/' | cut -c4-
|
16
|
+
exit
|
17
|
+
}
|
18
|
+
|
19
|
+
while getopts ":hd:" OPT; do
|
20
|
+
case $OPT in
|
21
|
+
d) cd $OPTARG ;;
|
22
|
+
h) usage ;;
|
23
|
+
\?) error "invalid option: -$OPTARG" ;;
|
24
|
+
:) error "option -$OPTARG requires an argument" ;;
|
25
|
+
esac
|
26
|
+
done
|
27
|
+
|
28
|
+
shift $((OPTIND-1))
|
29
|
+
|
30
|
+
command=$1
|
31
|
+
|
32
|
+
if [ "$1" == "" ]; then
|
33
|
+
usage
|
34
|
+
fi
|
35
|
+
|
2
36
|
exec $1 2>&1
|
data/lib/foreman/process.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "foreman"
|
2
|
+
require "rubygems"
|
2
3
|
|
3
4
|
class Foreman::Process
|
4
5
|
|
@@ -14,10 +15,8 @@ class Foreman::Process
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def run(pipe, basedir, environment)
|
17
|
-
|
18
|
-
|
19
|
-
run_process entry.command, pipe
|
20
|
-
end
|
18
|
+
with_environment(environment.merge("PORT" => port.to_s)) do
|
19
|
+
run_process basedir, entry.command, pipe
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
@@ -27,21 +26,33 @@ class Foreman::Process
|
|
27
26
|
|
28
27
|
private
|
29
28
|
|
30
|
-
def
|
29
|
+
def jruby?
|
30
|
+
defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java"
|
31
|
+
end
|
32
|
+
|
33
|
+
def fork_with_io(command, basedir)
|
31
34
|
reader, writer = IO.pipe
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
command = replace_command_env(command)
|
36
|
+
pid = if jruby?
|
37
|
+
require "posix/spawn"
|
38
|
+
POSIX::Spawn.spawn(Foreman.runner, "-d", basedir, command, {
|
39
|
+
:out => writer, :err => writer
|
40
|
+
})
|
41
|
+
else
|
42
|
+
fork do
|
43
|
+
trap("INT", "IGNORE")
|
44
|
+
writer.sync = true
|
45
|
+
$stdout.reopen writer
|
46
|
+
$stderr.reopen writer
|
47
|
+
reader.close
|
48
|
+
exec Foreman.runner, "-d", basedir, command
|
49
|
+
end
|
39
50
|
end
|
40
51
|
[ reader, pid ]
|
41
52
|
end
|
42
53
|
|
43
|
-
def run_process(command, pipe)
|
44
|
-
io, @pid = fork_with_io(command)
|
54
|
+
def run_process(basedir, command, pipe)
|
55
|
+
io, @pid = fork_with_io(command, basedir)
|
45
56
|
output pipe, "started with pid %d" % @pid
|
46
57
|
Thread.new do
|
47
58
|
until io.eof?
|
data/lib/foreman/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.37.0.pre1
|
5
|
+
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David Dollar
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: term-ansicolor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70172598141120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70172598141120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &70172598140300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.13.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70172598140300
|
36
36
|
description: Process manager for applications with multiple components
|
37
37
|
email: ddollar@gmail.com
|
38
38
|
executables:
|
@@ -106,21 +106,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- - ! '>='
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
hash: 3775390511397259528
|
112
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
110
|
none: false
|
114
111
|
requirements:
|
115
|
-
- - ! '
|
112
|
+
- - ! '>'
|
116
113
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
hash: 3775390511397259528
|
114
|
+
version: 1.3.1
|
121
115
|
requirements: []
|
122
116
|
rubyforge_project:
|
123
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.15
|
124
118
|
signing_key:
|
125
119
|
specification_version: 3
|
126
120
|
summary: Process manager for applications with multiple components
|