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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8852c64e45de97691310f1c9fd17bef228a9ea87db2085377cee1cd404546752
4
- data.tar.gz: 54afa19849d245f44f8d5e03c69d82e30015ff95978b266cad0db3919eb82195
3
+ metadata.gz: 0c9cd93e1cf950c5f7977d700a2d8b307faa98182af93063c55ced580617d054
4
+ data.tar.gz: 2de7767e855c5914d6db7678ef2c2302c414a20b04cb6dd4df7294263ee00f95
5
5
  SHA512:
6
- metadata.gz: 4a1799f87c74aa10807ea642d217686f208fe2de5444b4a87c540a8685e419d4c88b272e03faa83a9756fa7ef4e996f3cd8195f730ae43e97800e4666fecae59
7
- data.tar.gz: ab1dd31d7555502d566803ba4e87965e2431bb6d32c67cc6e0e39f7ac1c6c5369e22b1b6c7f6e3abb8cfdcccf6b4432029ba10b277171931f6a5fa05ed792d8d
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
- _pid, status = Process.wait2(@pid)
162
- @status = status.exitstatus
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)
@@ -4,6 +4,7 @@ require 'smart_proxy_dynflow/runner/command'
4
4
 
5
5
  module Proxy::Dynflow
6
6
  module Runner
7
+ # This class is now soft-deprecated, see {::Proxy::Dynflow::Runner::Command}
7
8
  class CommandRunner < Base
8
9
  include Command
9
10
  end
@@ -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
- publish_exception("Error running command '#{command.join(' ')}'", @process_manager.stderr.to_s)
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
 
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Dynflow
3
- VERSION = '0.8.0'.freeze
3
+ VERSION = '0.8.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas