frontkick 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +8 -0
- data/example/kill_child.rb +5 -0
- data/lib/frontkick/command.rb +30 -0
- data/lib/frontkick/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c05169903b48aeb4fd103f0f8eeac55b2c0b670
|
4
|
+
data.tar.gz: fc7d0c173417b7f3f4c24b0551a35a3b43b7b534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea20bd4b9dddee6bb5ab47f43c9334ec0d6ce1cde77a9b6660110ce32351a6bf31f699dd72e5d5d757baa964ff0483606082b61131762e489d0da6132f807963
|
7
|
+
data.tar.gz: 3cd1984f02b98b548190c0a37843c2ceee42ee79ed89149f036f18f376f519c793fbcf0675c028c931b8c015e3883b411804d2a0751f00d2fe3cf8aa9e89782d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,14 @@ If you prefer to be blocked:
|
|
54
54
|
|
55
55
|
Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock", :exclusive_blocking => true)
|
56
56
|
|
57
|
+
### Kill Child Option
|
58
|
+
|
59
|
+
On receiving INT and TERM signal, kill the kicked child process before exiting
|
60
|
+
|
61
|
+
Frontkick.exec("sleep 100", :kill_child => true)
|
62
|
+
|
63
|
+
NOTE: This uses Kernel.trap inside.
|
64
|
+
|
57
65
|
### Hint: Redirect stderr to stdout
|
58
66
|
|
59
67
|
Frontkick itself does not aid anything, but you can do as
|
data/lib/frontkick/command.rb
CHANGED
@@ -26,10 +26,18 @@ module Frontkick
|
|
26
26
|
err_reader = Thread.new { err.read }
|
27
27
|
stdin.close
|
28
28
|
pid = wait_thr.pid
|
29
|
+
|
30
|
+
trapped_signal = nil
|
31
|
+
if opts[:kill_child]
|
32
|
+
trap_signal(pid) {|sig| trapped_signal = sig }
|
33
|
+
end
|
34
|
+
|
29
35
|
stdout = out_reader.value
|
30
36
|
stderr = err_reader.value
|
31
37
|
exit_code = wait_thr.value.exitstatus
|
32
38
|
process_wait(pid)
|
39
|
+
|
40
|
+
exit_signal(trapped_signal) if trapped_signal
|
33
41
|
end
|
34
42
|
end
|
35
43
|
rescue Frontkick::TimeoutLocal => e
|
@@ -50,6 +58,28 @@ module Frontkick
|
|
50
58
|
Result.new(:stdout => stdout, :stderr => stderr, :exit_code => exit_code, :duration => duration)
|
51
59
|
end
|
52
60
|
|
61
|
+
def self.trap_signal(pid)
|
62
|
+
trap :INT do
|
63
|
+
Process.kill(:INT, pid)
|
64
|
+
yield(:INT)
|
65
|
+
end
|
66
|
+
trap :TERM do
|
67
|
+
Process.kill(:TERM, pid)
|
68
|
+
yield(:TERM)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.exit_signal(signal)
|
73
|
+
case signal
|
74
|
+
when :INT
|
75
|
+
exit(130)
|
76
|
+
when :TERM
|
77
|
+
exit(143)
|
78
|
+
else
|
79
|
+
raise 'Non supported signal'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
53
83
|
def self.process_wait(pid)
|
54
84
|
begin
|
55
85
|
pid, status = Process.waitpid2(pid) # wait child processes finish
|
data/lib/frontkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- example/dry_run.rb
|
71
|
+
- example/kill_child.rb
|
71
72
|
- example/run.rb
|
72
73
|
- experiment/capture3_no_deadlock.rb
|
73
74
|
- experiment/cat_63k.rb
|