svelte-on-rails 23.0.3 → 23.1.0
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/lib/svelte-on-rails.rb +4 -0
- data/lib/svelte_on_rails/cache.rb +56 -0
- data/lib/svelte_on_rails/configuration.rb +2 -2
- data/lib/tasks/cache_tasks.rake +1 -53
- data/lib/tasks/ssr_client_tasks.rake +34 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26d47863e0d0203a1e3eb22d690621ec1710f24b2f6e6808af0bebb159e8c658
|
|
4
|
+
data.tar.gz: bda202fb4a438357d2d50d74caf97cb1aa9bc8b4408b7adb758dd9b2c3e50476
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44513e768c709b976ec016a2381a95565b6d933da6a9fe4d81fcc534e2e35ec5a4a6a76cb1fae659b0eb54531468a9e8c940cb3648f8465b120b6eca780b4a37
|
|
7
|
+
data.tar.gz: d4c83202c7c4137c715fa54cd1ca6f80a7be1be2bc71291a6a6e15b66fd47e36d642752a94e98e26d1b2ce49eb6a890822c8f01bb2568488dbe631bb502eb8fa
|
data/lib/svelte-on-rails.rb
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module SvelteOnRails
|
|
2
|
+
module Cache
|
|
3
|
+
module_function
|
|
4
|
+
|
|
5
|
+
def redis_entries(silent: false)
|
|
6
|
+
conf = SvelteOnRails::Configuration.instance
|
|
7
|
+
redis = conf.redis_instance
|
|
8
|
+
namespace = conf.redis_namespace
|
|
9
|
+
|
|
10
|
+
unless redis
|
|
11
|
+
warn "svelte_on_rails:show_cache — no redis_instance configured, nothing to show."
|
|
12
|
+
return []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
pattern = "#{namespace}*"
|
|
16
|
+
|
|
17
|
+
puts "Scanning Redis for keys matching «#{pattern}» ..." unless silent
|
|
18
|
+
|
|
19
|
+
entries = [] # [{ key:, bytes:, ttl:, type: }]
|
|
20
|
+
cursor = "0"
|
|
21
|
+
|
|
22
|
+
loop do
|
|
23
|
+
cursor, keys = redis.scan(cursor, match: pattern)
|
|
24
|
+
|
|
25
|
+
if keys.any?
|
|
26
|
+
# Pipeline MEMORY USAGE / TTL / TYPE for the whole batch.
|
|
27
|
+
results = redis.pipelined do |p|
|
|
28
|
+
keys.each do |k|
|
|
29
|
+
p.call(["MEMORY", "USAGE", k])
|
|
30
|
+
p.ttl(k)
|
|
31
|
+
p.type(k)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
keys.each_with_index do |k, i|
|
|
36
|
+
bytes = results[i * 3]
|
|
37
|
+
ttl = results[i * 3 + 1]
|
|
38
|
+
type = results[i * 3 + 2]
|
|
39
|
+
entries << { key: k, bytes: bytes.to_i, ttl: ttl.to_i, type: type }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
break if cursor == "0"
|
|
44
|
+
rescue => e
|
|
45
|
+
warn "svelte_on_rails:show_cache — error during scan: #{e.class}: #{e.message}"
|
|
46
|
+
break
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
if entries.empty?
|
|
50
|
+
puts "No keys found under «#{pattern}»."
|
|
51
|
+
return []
|
|
52
|
+
end
|
|
53
|
+
entries
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -314,8 +314,8 @@ module SvelteOnRails
|
|
|
314
314
|
|
|
315
315
|
# npm package version
|
|
316
316
|
|
|
317
|
-
if Gem::Version.new(version) < Gem::Version.new('15.
|
|
318
|
-
raise "[Svelte-on-Rails] NPM-Package @csedl/svelte-on-rails: At least version 15.
|
|
317
|
+
if Gem::Version.new(version) < Gem::Version.new('15.2.0')
|
|
318
|
+
raise "[Svelte-on-Rails] NPM-Package @csedl/svelte-on-rails: At least version 15.2.0 is required, but found: «#{sor}»"
|
|
319
319
|
end
|
|
320
320
|
|
|
321
321
|
# check version
|
data/lib/tasks/cache_tasks.rake
CHANGED
|
@@ -52,7 +52,7 @@ namespace :svelte_on_rails do
|
|
|
52
52
|
desc "Show all svelte-on-rails Redis keys with their memory footprint (scoped to redis_namespace). Env: LIMIT=n, SORT=size|key, PATTERN=extra-glob"
|
|
53
53
|
task show: :environment do
|
|
54
54
|
|
|
55
|
-
_entries =
|
|
55
|
+
_entries = SvelteOnRails::Cache.redis_entries
|
|
56
56
|
|
|
57
57
|
_entries.sort_by! { |e| -e[:bytes] }
|
|
58
58
|
|
|
@@ -104,58 +104,6 @@ namespace :svelte_on_rails do
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
end
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def entries
|
|
110
|
-
conf = SvelteOnRails::Configuration.instance
|
|
111
|
-
redis = conf.redis_instance
|
|
112
|
-
namespace = conf.redis_namespace
|
|
113
|
-
|
|
114
|
-
unless redis
|
|
115
|
-
warn "svelte_on_rails:show_cache — no redis_instance configured, nothing to show."
|
|
116
|
-
return []
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
pattern = "#{namespace}*"
|
|
120
|
-
|
|
121
|
-
puts "Scanning Redis for keys matching «#{pattern}» ..."
|
|
122
|
-
|
|
123
|
-
entries = [] # [{ key:, bytes:, ttl:, type: }]
|
|
124
|
-
cursor = "0"
|
|
125
|
-
|
|
126
|
-
loop do
|
|
127
|
-
cursor, keys = redis.scan(cursor, match: pattern)
|
|
128
|
-
|
|
129
|
-
if keys.any?
|
|
130
|
-
# Pipeline MEMORY USAGE / TTL / TYPE for the whole batch.
|
|
131
|
-
results = redis.pipelined do |p|
|
|
132
|
-
keys.each do |k|
|
|
133
|
-
p.call(["MEMORY", "USAGE", k])
|
|
134
|
-
p.ttl(k)
|
|
135
|
-
p.type(k)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
keys.each_with_index do |k, i|
|
|
140
|
-
bytes = results[i * 3]
|
|
141
|
-
ttl = results[i * 3 + 1]
|
|
142
|
-
type = results[i * 3 + 2]
|
|
143
|
-
entries << { key: k, bytes: bytes.to_i, ttl: ttl.to_i, type: type }
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
break if cursor == "0"
|
|
148
|
-
rescue => e
|
|
149
|
-
warn "svelte_on_rails:show_cache — error during scan: #{e.class}: #{e.message}"
|
|
150
|
-
break
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
if entries.empty?
|
|
154
|
-
puts "No keys found under «#{pattern}»."
|
|
155
|
-
return []
|
|
156
|
-
end
|
|
157
|
-
entries
|
|
158
|
-
end
|
|
159
107
|
end
|
|
160
108
|
end
|
|
161
109
|
|
|
@@ -13,6 +13,8 @@ namespace :svelte_on_rails do
|
|
|
13
13
|
configs = SvelteOnRails::Configuration.instance
|
|
14
14
|
socket_path = client_status[:socket_path]
|
|
15
15
|
|
|
16
|
+
puts client_status.to_s
|
|
17
|
+
|
|
16
18
|
puts
|
|
17
19
|
puts '=' * @line_width
|
|
18
20
|
puts
|
|
@@ -50,6 +52,38 @@ namespace :svelte_on_rails do
|
|
|
50
52
|
puts
|
|
51
53
|
end
|
|
52
54
|
|
|
55
|
+
# MEMORY USAGE
|
|
56
|
+
|
|
57
|
+
puts '=' * @line_width
|
|
58
|
+
puts
|
|
59
|
+
puts 'MEMORY USAGE:'
|
|
60
|
+
puts
|
|
61
|
+
if !curl_installed
|
|
62
|
+
puts ' ERROR: curl is not installed on this machine, unable to check memory usage for node server.'
|
|
63
|
+
else
|
|
64
|
+
curl_cmd2 = "curl --unix-socket #{socket_path} http://localhost/health"
|
|
65
|
+
stdout, stderr, status = Open3.capture3(curl_cmd2)
|
|
66
|
+
pids = JSON.parse(stdout)['pids']
|
|
67
|
+
|
|
68
|
+
if pids.empty?
|
|
69
|
+
puts ' Node workers memory: no node worker PIDs found'
|
|
70
|
+
else
|
|
71
|
+
ps_cmd = "ps -o rss= -p #{pids.join(',')}"
|
|
72
|
+
ps_stdout, ps_stderr, ps_status = Open3.capture3(ps_cmd)
|
|
73
|
+
total_kb = ps_stdout.each_line.sum { |line| line.to_i }
|
|
74
|
+
|
|
75
|
+
puts " #{human_bytes(total_kb*1024)} for #{pids.size} node #{'worker'.pluralize(pids.size)}"
|
|
76
|
+
|
|
77
|
+
redis_entries = SvelteOnRails::Cache.redis_entries(silent: true)
|
|
78
|
+
total_bytes = redis_entries.sum { |e| e[:bytes] }
|
|
79
|
+
puts " #{human_bytes(total_bytes)} for #{redis_entries.size} Redis #{'key'.pluralize(redis_entries.size)}"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
puts
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# ADDITIONAL INFO
|
|
86
|
+
|
|
53
87
|
puts '=' * @line_width
|
|
54
88
|
puts
|
|
55
89
|
puts 'ADDITIONAL INFO:'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: svelte-on-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 23.0
|
|
4
|
+
version: 23.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Sedlmair
|
|
@@ -75,6 +75,7 @@ files:
|
|
|
75
75
|
- lib/svelte-on-rails.rb
|
|
76
76
|
- lib/svelte_on_rails/action_cable.rb
|
|
77
77
|
- lib/svelte_on_rails/active_record_extensions.rb
|
|
78
|
+
- lib/svelte_on_rails/cache.rb
|
|
78
79
|
- lib/svelte_on_rails/configuration.rb
|
|
79
80
|
- lib/svelte_on_rails/installer/gem_utils.rb
|
|
80
81
|
- lib/svelte_on_rails/installer/haml.rb
|