mediakit 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mediakit/process/runner.rb +15 -7
- data/lib/mediakit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 107e031c77eff9e854d35d6f1645b3e934ca9136
|
4
|
+
data.tar.gz: e4f10d51c9f694e06576dc17ce55ae8a39b00d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9380bfc22cb3c72d33af11864bd2e67ec4be24865dd1360695a981f0eac683bd150071806234ca61eb97b2d08c787e12eacbdcde9355f5be7617a9defb2bf848
|
7
|
+
data.tar.gz: 8510cf29d66fa761e936beea7456e0d8b2e7e247bdf86a2e7cd5f2b7f266b53070715e88a5391ae9fe31b260f76472c17596e277a3ebbbefd57479387fe99fed
|
@@ -46,20 +46,21 @@ module Mediakit
|
|
46
46
|
|
47
47
|
def wait(stdout, stderr, wait_thread)
|
48
48
|
begin
|
49
|
-
setup_watchers(stderr)
|
49
|
+
setup_watchers(stdout, stderr)
|
50
50
|
loop_thread = Thread.new { run_loop }
|
51
51
|
wait_thread.join
|
52
52
|
exit_status = (wait_thread.value.exitstatus == 0)
|
53
|
-
output = stdout.read
|
54
53
|
rescue Timeout::Error => error
|
55
54
|
force_kill_process(wait_thread.pid)
|
56
55
|
raise(error)
|
57
56
|
ensure
|
58
57
|
teardown_watchers
|
59
58
|
loop_thread.join if loop_thread
|
59
|
+
@out_watcher.read
|
60
|
+
@err_watcher.read
|
60
61
|
end
|
61
62
|
|
62
|
-
[exit_status,
|
63
|
+
[exit_status, @out_watcher.data, @err_watcher.data]
|
63
64
|
end
|
64
65
|
|
65
66
|
def build_command(bin, *args)
|
@@ -76,11 +77,13 @@ module Mediakit
|
|
76
77
|
"#{bin} #{escaped_args}"
|
77
78
|
end
|
78
79
|
|
79
|
-
def setup_watchers(stderr)
|
80
|
+
def setup_watchers(stdout, stderr)
|
80
81
|
@timer = @timeout ? TimeoutTimer.new(@timeout, Thread.current) : nil
|
81
|
-
@out_watcher = IOWatcher.new(
|
82
|
+
@out_watcher = IOWatcher.new(stdout) { |data| @timer.update if @timer; logger.info(data); }
|
83
|
+
@err_watcher = IOWatcher.new(stderr) { |data| @timer.update if @timer; logger.info(data); }
|
82
84
|
@loop = Coolio::Loop.new
|
83
85
|
@out_watcher.attach(@loop)
|
86
|
+
@err_watcher.attach(@loop)
|
84
87
|
@timer.attach(@loop) if @timer
|
85
88
|
end
|
86
89
|
|
@@ -94,7 +97,6 @@ module Mediakit
|
|
94
97
|
|
95
98
|
def teardown_watchers
|
96
99
|
@loop.watchers.each { |w| w.detach if w.attached? }
|
97
|
-
@out_watcher.close if @out_watcher && !@out_watcher.closed?
|
98
100
|
@loop.stop if @loop.has_active_watchers?
|
99
101
|
rescue RuntimeError => e
|
100
102
|
logger.warn(e.message)
|
@@ -108,9 +110,10 @@ module Mediakit
|
|
108
110
|
end
|
109
111
|
|
110
112
|
class IOWatcher < Coolio::IO
|
111
|
-
attr_reader(:data)
|
113
|
+
attr_reader(:io, :data)
|
112
114
|
|
113
115
|
def initialize(io, &block)
|
116
|
+
@io = io
|
114
117
|
@block = block
|
115
118
|
@data = ''
|
116
119
|
super
|
@@ -124,6 +127,11 @@ module Mediakit
|
|
124
127
|
def on_close
|
125
128
|
@block = nil
|
126
129
|
end
|
130
|
+
|
131
|
+
def read
|
132
|
+
@data << @io.read unless @io.closed?
|
133
|
+
@io.close unless @io.closed?
|
134
|
+
end
|
127
135
|
end
|
128
136
|
|
129
137
|
class TimeoutTimer < Coolio::TimerWatcher
|
data/lib/mediakit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediakit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ainame
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|