smart_proxy_dynflow 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_proxy_dynflow/process_manager.rb +7 -5
- data/lib/smart_proxy_dynflow/runner/command.rb +13 -0
- data/lib/smart_proxy_dynflow/runner/command_runner.rb +1 -0
- data/lib/smart_proxy_dynflow/runner/process_manager_command.rb +10 -2
- data/lib/smart_proxy_dynflow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c9cd93e1cf950c5f7977d700a2d8b307faa98182af93063c55ced580617d054
|
4
|
+
data.tar.gz: 2de7767e855c5914d6db7678ef2c2302c414a20b04cb6dd4df7294263ee00f95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03995ac1c1bf44c900926371d3b42c56f05dc8b994fb07f3c87613e788a990e9ec597d67bb24a97279ae4bc0557fca01dabfbaace26299553467f8173ff8f73
|
7
|
+
data.tar.gz: 0d4737d0298d940988c51ba62e04c45740530660ae76c492e706459965446e984f2ddeb319651a416864636dca407d4f281029bb75da9ad747da7f6b6d71ee42
|
@@ -76,12 +76,12 @@ module Proxy
|
|
76
76
|
out_read, out_write = IO.pipe
|
77
77
|
err_read, err_write = IO.pipe
|
78
78
|
|
79
|
-
@pid = spawn(*@command, :in => in_read, :out => out_write, :err => err_write)
|
80
|
-
[in_read, out_write, err_write].each(&:close)
|
81
|
-
|
82
79
|
@stdin.io = in_write
|
83
80
|
@stdout.io = out_read
|
84
81
|
@stderr.io = err_read
|
82
|
+
|
83
|
+
@pid = spawn(*@command, :in => in_read, :out => out_write, :err => err_write)
|
84
|
+
[in_read, out_write, err_write].each(&:close)
|
85
85
|
rescue Errno::ENOENT => e
|
86
86
|
[in_read, in_write, out_read, out_write, err_read, err_write].each(&:close)
|
87
87
|
@pid = -1
|
@@ -158,8 +158,10 @@ module Proxy
|
|
158
158
|
# @return [void]
|
159
159
|
def finish
|
160
160
|
close
|
161
|
-
|
162
|
-
|
161
|
+
unless @pid == -1
|
162
|
+
_pid, status = Process.wait2(@pid)
|
163
|
+
@status = status.exitstatus
|
164
|
+
end
|
163
165
|
end
|
164
166
|
end
|
165
167
|
end
|
@@ -1,5 +1,18 @@
|
|
1
1
|
module Proxy::Dynflow
|
2
2
|
module Runner
|
3
|
+
# This module expects to be included into a Runner action, where it can be
|
4
|
+
# used to simplify handling of long-running processes. However it tracks the
|
5
|
+
# running process as a group of instance variables, which has served us
|
6
|
+
# reasonably well in the past, but can be rather error prone.
|
7
|
+
#
|
8
|
+
# A better alternative to this is
|
9
|
+
# {::Proxy::Dynflow::Runner::ProcessManagerCommand}. It tracks the whole
|
10
|
+
# execution of a process under a single instance variable and uses a more
|
11
|
+
# robust {::Proxy::Dynflow::ProcessManager} under the hood. It also
|
12
|
+
# maintains the same interface and can be used as a drop-in replacement.
|
13
|
+
#
|
14
|
+
# This module is now soft-deprecated and
|
15
|
+
# {::Proxy::Dynflow::Runner::ProcessManagerCommand} should be used instead.
|
3
16
|
module Command
|
4
17
|
def initialize_command(*command)
|
5
18
|
@command_out, @command_in, @command_pid = PTY.spawn(*command)
|
@@ -2,13 +2,21 @@ require 'smart_proxy_dynflow/process_manager'
|
|
2
2
|
|
3
3
|
module Proxy::Dynflow
|
4
4
|
module Runner
|
5
|
+
# A convenience module which should be included into a Runner action. It
|
6
|
+
# leverages {::Proxy::Dynflow::ProcessManager} to reliably keep track of
|
7
|
+
# an external process and collect its output.
|
8
|
+
#
|
9
|
+
# The only expectation from the Runner action is to call
|
10
|
+
# {#initialize_command} somewhere and pass the command to be run to it.
|
5
11
|
module ProcessManagerCommand
|
6
12
|
def initialize_command(*command)
|
7
13
|
@process_manager = ProcessManager.new(command)
|
8
14
|
set_process_manager_callbacks(@process_manager)
|
9
15
|
@process_manager.start!
|
10
16
|
if @process_manager.done? && @process_manager.status == 255
|
11
|
-
|
17
|
+
exception = RuntimeError.new(@process_manager.stderr.to_s)
|
18
|
+
exception.set_backtrace Thread.current.backtrace
|
19
|
+
publish_exception("Error running command '#{command.join(' ')}'", exception)
|
12
20
|
end
|
13
21
|
end
|
14
22
|
|
@@ -24,7 +32,7 @@ module Proxy::Dynflow
|
|
24
32
|
end
|
25
33
|
|
26
34
|
def refresh
|
27
|
-
@process_manager.process(timeout: 0.1)
|
35
|
+
@process_manager.process(timeout: 0.1) unless @process_manager.done?
|
28
36
|
publish_exit_status(@process_manager.status) if @process_manager.done?
|
29
37
|
end
|
30
38
|
|