bidi2pdf 0.1.2 โ 0.1.3
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/.rubocop.yml +10 -0
- data/CHANGELOG.md +12 -0
- data/cliff.toml +50 -26
- data/docker/nginx/default.conf +6 -0
- data/lib/bidi2pdf/bidi/client.rb +9 -8
- data/lib/bidi2pdf/bidi/session.rb +4 -13
- data/lib/bidi2pdf/chromedriver_manager.rb +21 -12
- data/lib/bidi2pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715f3587349e1680386f0c485f45b91a6096143c07cc8b531ca7e284a9516615
|
4
|
+
data.tar.gz: 8914fd60cdb04510070dee6b6d7134a94666584583681e26e830824bbf457059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e17273531b0131ef9e8b5454154996dbd340d18cbf16a151478b91234e1e53005e0ffb057e16d540f6870b8915bafbdf03831afc2d9b4e9d861494ca13c38f
|
7
|
+
data.tar.gz: d0a4d3b193fc51b681a2e3b54da5cc7cccf05cf578b908144eb7ca5988327f0ee938b07dce88ca826d37889a469e3f32a7da61c68bbb05b5913731aeb0cc9e38
|
data/.rubocop.yml
CHANGED
@@ -48,6 +48,16 @@ RSpec/InstanceVariable:
|
|
48
48
|
RSpec/BeforeAfterAll:
|
49
49
|
Enabled: false
|
50
50
|
|
51
|
+
RSpec/SpecFilePathFormat:
|
52
|
+
Enabled: true
|
53
|
+
Exclude:
|
54
|
+
- 'spec/acceptance/**/*_spec.rb'
|
55
|
+
|
56
|
+
RSpec/DescribeClass:
|
57
|
+
Enabled: true
|
58
|
+
Exclude:
|
59
|
+
- 'spec/acceptance/**/*_spec.rb'
|
60
|
+
|
51
61
|
plugins:
|
52
62
|
- rubocop-rake
|
53
63
|
- rubocop-rspec
|
data/CHANGELOG.md
CHANGED
@@ -6,8 +6,20 @@ All notable changes to this project will be documented in this file.
|
|
6
6
|
|
7
7
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
8
8
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
9
|
+
|
10
|
+
## [Unreleased]
|
11
|
+
|
12
|
+
[unreleased]: https://github.com/dieter-medium/bidi2pdf/compare/v0.1.2..HEAD
|
13
|
+
|
9
14
|
<!-- generated by git-cliff end -->
|
10
15
|
|
16
|
+
## [0.1.3] - 2025-04-06
|
17
|
+
|
18
|
+
### ๐ Fixed
|
19
|
+
|
20
|
+
- Improve zombie process detection and termination logic in Chromedriver manager by @dieter-medium
|
21
|
+
- Add close method for WebSocket connection and update session close logic. Don't leak threads. by @dieter-medium
|
22
|
+
|
11
23
|
## [0.1.2] - 2025-04-05
|
12
24
|
|
13
25
|
### ๐ Changed
|
data/cliff.toml
CHANGED
@@ -79,33 +79,57 @@ commit_preprocessors = [
|
|
79
79
|
]
|
80
80
|
# regex for parsing and grouping commits
|
81
81
|
commit_parsers = [
|
82
|
-
# โ
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
82
|
+
# โ
Features (additions)
|
83
|
+
{ message = "^feat(?:\\([^)]+\\))?!?:", group = "๐ Added" },
|
84
|
+
{ message = "^[aA]dd", group = "๐ Added" },
|
85
|
+
{ message = "^[sS]upport", group = "๐ Added" },
|
86
|
+
|
87
|
+
# โ Removals
|
88
|
+
{ message = "^[rR]emove", group = "๐๏ธ Removed" },
|
89
|
+
{ message = "^[dD]elete", group = "๐๏ธ Removed" },
|
90
|
+
|
91
|
+
# ๐ Fixes
|
92
|
+
{ message = "^fix(?:\\([^)]+\\))?!?:", group = "๐ Fixed" },
|
93
|
+
{ message = "^[tT]est", group = "๐ Fixed" },
|
94
|
+
{ message = "^[fF]ix", group = "๐ Fixed" },
|
95
|
+
|
96
|
+
# ๐จ Refactors
|
97
|
+
{ message = "^refactor(?:\\([^)]+\\))?!?:", group = "๐จ Refactored" },
|
98
|
+
|
99
|
+
# โก๏ธ Performance
|
100
|
+
{ message = "^perf(?:\\([^)]+\\))?!?:", group = "โก๏ธ Performance" },
|
101
|
+
|
102
|
+
# ๐ Docs
|
103
|
+
{ message = "^docs(?:\\([^)]+\\))?!?:", group = "๐ Docs" },
|
104
|
+
|
105
|
+
# ๐ Style (formatting, whitespace, etc.)
|
106
|
+
{ message = "^style(?:\\([^)]+\\))?!?:", group = "๐ Style" },
|
107
|
+
|
108
|
+
# ๐งช Tests
|
109
|
+
{ message = "^test(?:\\([^)]+\\))?!?:", group = "๐งช Tests" },
|
110
|
+
|
111
|
+
# ๐ง Build
|
112
|
+
{ message = "^build(?:\\([^)]+\\))?!?:", group = "๐ง Build" },
|
113
|
+
|
114
|
+
# ๐ ๏ธ CI
|
115
|
+
{ message = "^ci(?:\\([^)]+\\))?!?:", skip = true },
|
116
|
+
|
117
|
+
# ๐งน Chores (skip)
|
118
|
+
{ message = "^chore\\(release\\): prepare for", skip = true },
|
119
|
+
{ message = "^chore\\(deps.*\\)", skip = true },
|
120
|
+
{ message = "^chore\\(pr\\)", skip = true },
|
121
|
+
{ message = "^chore\\(pull\\)", skip = true },
|
122
|
+
{ message = "^chore(?:\\([^)]+\\))?!?:", skip = true },
|
123
|
+
{ message = "^\\s*chore", skip = true },
|
124
|
+
|
125
|
+
# โช Reverts
|
126
|
+
{ message = "^revert(?:\\([^)]+\\))?!?:", group = "โช Reverted" },
|
127
|
+
|
128
|
+
# ๐ Catch-all (only if nothing else matched)
|
129
|
+
{ message = "^.*", group = "๐ Changed" }
|
108
130
|
]
|
131
|
+
|
132
|
+
|
109
133
|
# filter out the commits that are not matched by commit parsers
|
110
134
|
filter_commits = false
|
111
135
|
# sort the tags topologically
|
data/docker/nginx/default.conf
CHANGED
data/lib/bidi2pdf/bidi/client.rb
CHANGED
@@ -18,14 +18,6 @@ module Bidi2pdf
|
|
18
18
|
|
19
19
|
def initialize(ws_url)
|
20
20
|
@ws_url = ws_url
|
21
|
-
@id = 0
|
22
|
-
@pending_responses = {}
|
23
|
-
|
24
|
-
@connected = false
|
25
|
-
@connection_mutex = Mutex.new
|
26
|
-
@next_id_mutex = Mutex.new
|
27
|
-
@connection_cv = ConditionVariable.new
|
28
|
-
|
29
21
|
@started = false
|
30
22
|
end
|
31
23
|
|
@@ -103,6 +95,15 @@ module Bidi2pdf
|
|
103
95
|
)
|
104
96
|
end
|
105
97
|
|
98
|
+
def close
|
99
|
+
return unless @socket
|
100
|
+
|
101
|
+
Bidi2pdf.logger.debug "Closing WebSocket connection"
|
102
|
+
@socket&.close
|
103
|
+
@socket = nil
|
104
|
+
@started = false
|
105
|
+
end
|
106
|
+
|
106
107
|
private
|
107
108
|
|
108
109
|
def dispatcher
|
@@ -10,19 +10,9 @@ require_relative "user_context"
|
|
10
10
|
module Bidi2pdf
|
11
11
|
module Bidi
|
12
12
|
class Session
|
13
|
-
SUBSCRIBE_EVENTS = [
|
14
|
-
|
15
|
-
|
16
|
-
"log",
|
17
|
-
"script",
|
18
|
-
"goog:cdp.Debugger.scriptParsed",
|
19
|
-
"goog:cdp.CSS.styleSheetAdded",
|
20
|
-
"goog:cdp.Runtime.executionContextsCleared",
|
21
|
-
# Tracing
|
22
|
-
"goog:cdp.Tracing.tracingComplete",
|
23
|
-
"goog:cdp.Network.requestWillBeSent",
|
24
|
-
"goog:cdp.Debugger.scriptParsed",
|
25
|
-
"goog:cdp.Page.screencastFrame"
|
13
|
+
SUBSCRIBE_EVENTS = %w[
|
14
|
+
log
|
15
|
+
script
|
26
16
|
].freeze
|
27
17
|
|
28
18
|
attr_reader :session_uri, :started
|
@@ -48,6 +38,7 @@ module Bidi2pdf
|
|
48
38
|
def close
|
49
39
|
client&.send_cmd_and_wait("session.end", {}) do |response|
|
50
40
|
Bidi2pdf.logger.debug "Session ended: #{response}"
|
41
|
+
@client&.close
|
51
42
|
@client = nil
|
52
43
|
@websocket_url = nil
|
53
44
|
@browser = nil
|
@@ -55,9 +55,11 @@ module Bidi2pdf
|
|
55
55
|
|
56
56
|
close_session
|
57
57
|
|
58
|
-
|
58
|
+
debug_show_all_children
|
59
|
+
|
60
|
+
old_childprocesses = term_chromedriver
|
59
61
|
|
60
|
-
detect_zombie_processes
|
62
|
+
detect_zombie_processes old_childprocesses
|
61
63
|
|
62
64
|
return unless process_alive?
|
63
65
|
|
@@ -68,14 +70,10 @@ module Bidi2pdf
|
|
68
70
|
|
69
71
|
private
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
debug_show_all_children
|
73
|
+
def detect_zombie_processes(old_childprocesses)
|
74
|
+
Bidi2pdf.logger.debug "Old child processes for #{@pid}: #{old_childprocesses.map(&:pid).join(", ")}"
|
74
75
|
|
75
|
-
|
76
|
-
Bidi2pdf.logger.debug "Found child processes: #{child_processes.map(&:pid).join(", ")}"
|
77
|
-
|
78
|
-
zombie_processes = child_processes.select { |child| process_alive? child.pid }
|
76
|
+
zombie_processes = old_childprocesses.select { |child| process_alive? child.pid }
|
79
77
|
|
80
78
|
return if zombie_processes.empty?
|
81
79
|
|
@@ -83,9 +81,18 @@ module Bidi2pdf
|
|
83
81
|
printable_zombie_processes_str = printable_zombie_processes.join(", ")
|
84
82
|
|
85
83
|
Bidi2pdf.logger.error "Zombie Processes detected #{printable_zombie_processes_str}"
|
84
|
+
|
85
|
+
term_zombie_processes zombie_processes
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
def term_zombie_processes(zombie_processes)
|
89
|
+
Bidi2pdf.logger.info "Terminating zombie processes: #{zombie_processes.map(&:pid).join(", ")}"
|
90
|
+
|
91
|
+
zombie_processes.each do |child|
|
92
|
+
Bidi2pdf.logger.debug "Terminating PID #{child.pid} (#{child.name})"
|
93
|
+
Process.kill("TERM", child.pid)
|
94
|
+
end
|
95
|
+
end
|
89
96
|
|
90
97
|
def debug_show_all_children
|
91
98
|
Bidi2pdf::ProcessTree.new(@pid).traverse do |process, level|
|
@@ -103,9 +110,11 @@ module Bidi2pdf
|
|
103
110
|
end
|
104
111
|
|
105
112
|
def term_chromedriver
|
106
|
-
Bidi2pdf.
|
113
|
+
Bidi2pdf::ProcessTree.new(@pid).children(@pid).tap do |_child_processes|
|
114
|
+
Bidi2pdf.logger.info "Stopping Chromedriver (PID #{@pid})"
|
107
115
|
|
108
|
-
|
116
|
+
Process.kill("TERM", @pid)
|
117
|
+
end
|
109
118
|
rescue Errno::ESRCH
|
110
119
|
Bidi2pdf.logger.debug "Process already gone"
|
111
120
|
@pid = nil
|
data/lib/bidi2pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bidi2pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dieter S.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|