pais_legacy 2.6.16 → 2.6.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pais_legacy/version.rb +1 -1
- data/lib/pais_legacy.rb +50 -40
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4bc027926acd33cf21596f062b32a7df8e255025e55ee0d91430efc731b24eaf
|
|
4
|
+
data.tar.gz: 6cdb3bad8eff90e4e092f5ee5b8ac7bfa5157c80e9902ae8eaecf33e96fcfb2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69c8e7b80e89a51907efeeae410cb387453b46884bc573ba00ea8a488c054f05f954b5801bc19cfc8b9a0aa3c782a6781df1ec23b3ad5e1ed091e55c8c6be849
|
|
7
|
+
data.tar.gz: 1a86989dbb53199054fed3d54bc795595a8c41c4a941c68ca9f41d0bda64c70656302c1afe5ff91ea193d54b999aeb3ef423edb31cd5354379e4190f9ea675dc
|
data/Gemfile.lock
CHANGED
data/lib/pais_legacy/version.rb
CHANGED
data/lib/pais_legacy.rb
CHANGED
|
@@ -31,36 +31,50 @@ module PaisLegacy
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.execute_ssh_command(command)
|
|
34
|
-
|
|
34
|
+
stdout = ''
|
|
35
|
+
stderr = ''
|
|
36
|
+
exit_status = nil
|
|
35
37
|
retries = 0
|
|
36
38
|
|
|
37
39
|
begin
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
stdout = ''
|
|
41
|
+
stderr = ''
|
|
42
|
+
exit_status = nil
|
|
43
|
+
|
|
44
|
+
# Start an SSH session.
|
|
45
|
+
#
|
|
46
|
+
# No pty is requested, deliberately. A pty merges the remote stderr
|
|
47
|
+
# into stdout, so any notice from the remote side (a `docker compose`
|
|
48
|
+
# "variable is not set" WARN, an ANSI colour code, a 4GL error) lands
|
|
49
|
+
# in the middle of the JSON we are about to parse. A pty also sets
|
|
50
|
+
# SSH_TTY, which makes the remote `fglgo` wrapper take its interactive
|
|
51
|
+
# branch: it names the 4GL container after the tty number and stops
|
|
52
|
+
# whatever already holds that name, so two callers landing on the same
|
|
53
|
+
# recycled tty number collide with each other.
|
|
40
54
|
Net::SSH.start(SERVER,USER,keys: [KEY]) do |ssh|
|
|
41
55
|
# Open a new SSH channel
|
|
42
56
|
ssh.open_channel do |channel|
|
|
43
|
-
#
|
|
44
|
-
channel.
|
|
45
|
-
raise 'Could not
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
ch.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
# Execute the command
|
|
58
|
+
channel.exec(command) do |ch, success|
|
|
59
|
+
raise 'Could not execute command' unless success
|
|
60
|
+
|
|
61
|
+
# Collect the data received from the command's standard output
|
|
62
|
+
ch.on_data do |c, data|
|
|
63
|
+
stdout += data
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Collect the data received from the command's standard error,
|
|
67
|
+
# kept apart from stdout so it cannot corrupt the payload
|
|
68
|
+
ch.on_extended_data do |c, type, data|
|
|
69
|
+
stderr += data
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
ch.on_request('exit-status') do |c, data|
|
|
73
|
+
exit_status = data.read_long
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
ch.on_close do
|
|
77
|
+
puts 'Command execution finished' if ENV['DEBUG'] == 'true'
|
|
64
78
|
end
|
|
65
79
|
end
|
|
66
80
|
end
|
|
@@ -69,31 +83,27 @@ module PaisLegacy
|
|
|
69
83
|
ssh.loop
|
|
70
84
|
end
|
|
71
85
|
|
|
72
|
-
rescue Net::SSH::ConnectionTimeout => e
|
|
86
|
+
rescue Net::SSH::ConnectionTimeout, Errno::ECONNRESET => e
|
|
73
87
|
retries += 1
|
|
74
88
|
if retries <= MAX_RETRIES
|
|
75
|
-
puts "
|
|
89
|
+
puts "#{e.class}, retrying (#{retries}/#{MAX_RETRIES})..." if ENV['DEBUG'] == 'true'
|
|
76
90
|
sleep RETRY_DELAY
|
|
77
91
|
retry
|
|
78
|
-
else
|
|
79
|
-
puts 'Max retries reached. Could not connect.' if ENV['DEBUG'] == 'true'
|
|
80
92
|
end
|
|
93
|
+
raise Error, "#{command}: #{e.class} after #{MAX_RETRIES} retries"
|
|
94
|
+
end
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
retry
|
|
88
|
-
else
|
|
89
|
-
puts 'Max retries reached. Could not connect.' if ENV['DEBUG'] == 'true'
|
|
90
|
-
end
|
|
96
|
+
# Fail loudly rather than handing back a partial or empty payload for
|
|
97
|
+
# the caller to trip over in JSON.parse.
|
|
98
|
+
unless exit_status.nil? || exit_status.zero?
|
|
99
|
+
raise Error, "#{command} exited #{exit_status}: #{stderr.strip}"
|
|
100
|
+
end
|
|
91
101
|
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
if stdout.empty? && !stderr.empty?
|
|
103
|
+
raise Error, "#{command} produced no output: #{stderr.strip}"
|
|
94
104
|
end
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
stdout
|
|
97
107
|
end
|
|
98
108
|
|
|
99
109
|
# delegate :execute_ssh_command, to: :class
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pais_legacy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.6.
|
|
4
|
+
version: 2.6.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Pope
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-09-15 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: pastel
|
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
requirements: []
|
|
77
|
-
rubygems_version: 3.6.
|
|
77
|
+
rubygems_version: 3.6.2
|
|
78
78
|
specification_version: 4
|
|
79
79
|
summary: PAIS Legacy API Wrapper
|
|
80
80
|
test_files: []
|