subcontractor 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/examples/Procfile CHANGED
@@ -1,3 +1,4 @@
1
1
  thin: ruby -I ../lib ../bin/subcontract --rvm ruby-1.8.7-p249@subcontractor-webapp --chdir webapp --signal INT -- bundle exec rackup config.ru -p 3001
2
2
  webrick: ruby -I ../lib ../bin/subcontract --rvm ruby-1.8.7-p249@subcontractor-webapp --chdir webapp --signal INT -- bundle exec thin --rackup config.ru -p 3002 start
3
3
  sleepy: ruby -I ../lib ../bin/subcontract --chdir script -- ruby sleepy.rb
4
+ slanger: ruby -I ../lib ../bin/subcontract --chdir slanger --rvm ruby-1.9.2@slanger -- bundle exec slanger --app_key xxx --secret xxx -w 0.0.0.0:8081
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.2@slanger --create
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "slanger"
@@ -11,7 +11,7 @@ module Subcontractor
11
11
  signal = options[:signal] || "TERM"
12
12
  PTY.spawn(command) do |stdin, stdout, pid|
13
13
  trap("TERM") do
14
- options.has_key?(:rvm) ? send_kill(signal, *child_pids(pid)) : send_kill(signal, pid)
14
+ send_kill(signal, find_pids_to_kill(pid))
15
15
  end
16
16
  until stdin.eof?
17
17
  puts stdin.gets
@@ -19,16 +19,24 @@ module Subcontractor
19
19
  end
20
20
  end
21
21
 
22
- def send_kill(signal, *pids)
22
+ def send_kill(signal, pids)
23
23
  pids.each { |pid| Process.kill(signal, pid) }
24
24
  end
25
25
 
26
- def child_pids(pid)
26
+ def find_pids_to_kill(*pids_to_investigate)
27
+ pids_to_kill = pids_to_investigate
28
+ begin
29
+ pids_to_investigate = find_child_pids(pids_to_investigate)
30
+ pids_to_kill = pids_to_investigate + pids_to_kill
31
+ end until pids_to_investigate.empty?
32
+ pids_to_kill
33
+ end
34
+
35
+ def find_child_pids(pids)
27
36
  lines = `ps axo pid,ppid`
28
37
  child_pids = lines.map(&:split).select do |(child_pid, parent_pid)|
29
- parent_pid == pid.to_s
38
+ pids.include?(parent_pid.to_i)
30
39
  end.map(&:first).map(&:to_i)
31
- child_pids + [pid]
32
40
  end
33
41
 
34
42
  def build_command(parts, options)
@@ -1,3 +1,3 @@
1
1
  module Subcontractor
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subcontractor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Pitluga
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-22 00:00:00 Z
18
+ date: 2011-12-30 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: rvm aware process launcher for foreman
@@ -36,6 +36,8 @@ files:
36
36
  - bin/subcontract
37
37
  - examples/Procfile
38
38
  - examples/script/sleepy.rb
39
+ - examples/slanger/.rvmrc
40
+ - examples/slanger/Gemfile
39
41
  - examples/webapp/.rvmrc
40
42
  - examples/webapp/Gemfile
41
43
  - examples/webapp/app.rb