svelte-on-rails 22.5.2 → 22.5.4
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/ssr_client.rb +6 -42
- data/lib/tasks/ssr_client_tasks.rake +1 -9
- 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: 1a6a1c4758093d4ee7080494a52d0a3709728dc830b7f0c261841363100ea593
|
|
4
|
+
data.tar.gz: 18d316a0a47d9c780d3169acd3edc525f4a097864302182b1398173ffd26aba7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af06be9fb96620f83701d90eb2745dc551329f25b1fceedf55e02f42150361f4d491b0ae5fb1279639761449a08dbab73861711c6776178d294bc84343f012c9
|
|
7
|
+
data.tar.gz: c8c362043c2872cb7b4bf8b89de643daca6accfca5d5d7937ed726f3f49dea6babe3b5501c43a9c497be5eb843b4195832b0cf1a97e3e856d9e836605a3feda6
|
|
@@ -11,10 +11,7 @@ module SvelteOnRails
|
|
|
11
11
|
:socket_path,
|
|
12
12
|
:ssr_server_bin_path,
|
|
13
13
|
:node_bin,
|
|
14
|
-
:initialized_by
|
|
15
|
-
:render_success_count,
|
|
16
|
-
:render_failure_count,
|
|
17
|
-
:error_log
|
|
14
|
+
:initialized_by
|
|
18
15
|
|
|
19
16
|
# methods
|
|
20
17
|
|
|
@@ -36,7 +33,7 @@ module SvelteOnRails
|
|
|
36
33
|
@socket_namespace = [
|
|
37
34
|
"svelte",
|
|
38
35
|
Rails.application.class.module_parent_name[0..15],
|
|
39
|
-
|
|
36
|
+
Rails.env
|
|
40
37
|
].join("-")
|
|
41
38
|
@socket_path = socket_path_fresh
|
|
42
39
|
|
|
@@ -46,10 +43,6 @@ module SvelteOnRails
|
|
|
46
43
|
@ssr_server_bin_path = SvelteOnRails::Configuration.instance.ssr_server_bin_path
|
|
47
44
|
@started = Time.now
|
|
48
45
|
|
|
49
|
-
@render_success_count = 0
|
|
50
|
-
@render_failure_count = 0
|
|
51
|
-
@error_log = []
|
|
52
|
-
|
|
53
46
|
File.delete(restart_marker_file) if File.exist?(restart_marker_file)
|
|
54
47
|
|
|
55
48
|
SvelteOnRails::SsrClientControlChannel.install_control_listener
|
|
@@ -91,9 +84,6 @@ module SvelteOnRails
|
|
|
91
84
|
socket.close
|
|
92
85
|
rescue => e
|
|
93
86
|
|
|
94
|
-
write_error_log(e)
|
|
95
|
-
@render_failure_count += 1
|
|
96
|
-
|
|
97
87
|
restart_my_server('Restart-after-failure')
|
|
98
88
|
|
|
99
89
|
SvelteOnRails::Lib::Utils.error_log(
|
|
@@ -113,7 +103,7 @@ module SvelteOnRails
|
|
|
113
103
|
|
|
114
104
|
raw_response = parse_body_json(response)
|
|
115
105
|
if raw_response['status'] == 'SUCCESS'
|
|
116
|
-
|
|
106
|
+
|
|
117
107
|
htm = raw_response['html'].to_s
|
|
118
108
|
.gsub('<!--[-->', '')
|
|
119
109
|
.gsub('<!--]-->', '')
|
|
@@ -135,9 +125,6 @@ module SvelteOnRails
|
|
|
135
125
|
''
|
|
136
126
|
end
|
|
137
127
|
|
|
138
|
-
write_error_log("Render #{component[:file_basename]}.svelte")
|
|
139
|
-
@render_failure_count += 1
|
|
140
|
-
|
|
141
128
|
utils = SvelteOnRails::Lib::Utils
|
|
142
129
|
utils.error_log(
|
|
143
130
|
:render_failed,
|
|
@@ -154,12 +141,6 @@ module SvelteOnRails
|
|
|
154
141
|
|
|
155
142
|
end
|
|
156
143
|
|
|
157
|
-
def write_error_log(msg)
|
|
158
|
-
timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S.%3N')
|
|
159
|
-
@error_log << "[#{timestamp}] #{msg}"
|
|
160
|
-
@error_log.shift while @error_log.size > 50
|
|
161
|
-
end
|
|
162
|
-
|
|
163
144
|
def parse_body_json(response_string)
|
|
164
145
|
return {} unless response_string.to_s.present?
|
|
165
146
|
|
|
@@ -472,13 +453,13 @@ module SvelteOnRails
|
|
|
472
453
|
# Sits next to the SSR socket in tmp/sockets, or in the /tmp/svelte
|
|
473
454
|
# fallback directory when Rails.root pushes total length over 103 chars.
|
|
474
455
|
def self.socket_path
|
|
475
|
-
primary = Rails.root.join("tmp", "sockets", "svelte-ctl-#{
|
|
456
|
+
primary = Rails.root.join("tmp", "sockets", "svelte-ctl-#{Rails.env}.sock")
|
|
476
457
|
if primary.to_s.length <= 103
|
|
477
458
|
FileUtils.mkdir_p(File.dirname(primary))
|
|
478
459
|
return primary
|
|
479
460
|
end
|
|
480
461
|
|
|
481
|
-
Pathname.new("/tmp/svelte-#{
|
|
462
|
+
Pathname.new("/tmp/svelte-#{Rails.env}-ctl-#{Digest::XXH64.hexdigest(Rails.root.to_s)}.sock")
|
|
482
463
|
end
|
|
483
464
|
|
|
484
465
|
# enable communication by rake task for admin purposes
|
|
@@ -507,10 +488,7 @@ module SvelteOnRails
|
|
|
507
488
|
socket_path: client_instance.socket_path,
|
|
508
489
|
initialized_by: client_instance.initialized_by,
|
|
509
490
|
ping: client_instance.ping?,
|
|
510
|
-
start_node_server_command: client_instance.start_node_server_command
|
|
511
|
-
render_success_count: client_instance.render_success_count,
|
|
512
|
-
render_failure_count: client_instance.render_failure_count,
|
|
513
|
-
error_log: client_instance.error_log
|
|
491
|
+
start_node_server_command: client_instance.start_node_server_command
|
|
514
492
|
}
|
|
515
493
|
when :stop
|
|
516
494
|
begin
|
|
@@ -549,20 +527,6 @@ module SvelteOnRails
|
|
|
549
527
|
|
|
550
528
|
end
|
|
551
529
|
|
|
552
|
-
def self.short_env
|
|
553
|
-
|
|
554
|
-
name = Rails.env.to_s
|
|
555
|
-
|
|
556
|
-
short = {
|
|
557
|
-
"development" => "dev",
|
|
558
|
-
"production" => "prod",
|
|
559
|
-
"staging" => "stage",
|
|
560
|
-
}[name]
|
|
561
|
-
|
|
562
|
-
return name unless short
|
|
563
|
-
return name if Rails.root.join("config", "environments", "#{short}.rb").exist?
|
|
564
|
-
short
|
|
565
|
-
end
|
|
566
530
|
end
|
|
567
531
|
|
|
568
532
|
class SsrError < StandardError; end
|
|
@@ -27,7 +27,6 @@ namespace :svelte_on_rails do
|
|
|
27
27
|
puts ' SSR Server bin : ' + configs.ssr_server_bin_path.to_s
|
|
28
28
|
puts " Socket (SsrServer) : #{socket_path} (#{File.socket?(socket_path) ? 'Present/OK' : 'NOT FOUND!'})"
|
|
29
29
|
puts " Ping to SsrServer : #{client_status[:ping] ? 'SUCCESS' : 'FAILED'}"
|
|
30
|
-
puts " SSR renders : #{client_status[:render_success_count]} succeeded, #{client_status[:render_failure_count]} failed"
|
|
31
30
|
puts
|
|
32
31
|
|
|
33
32
|
# NODE SERVER STATUS
|
|
@@ -55,13 +54,6 @@ namespace :svelte_on_rails do
|
|
|
55
54
|
puts
|
|
56
55
|
puts 'ADDITIONAL INFO:'
|
|
57
56
|
puts
|
|
58
|
-
if client_status[:error_log] == []
|
|
59
|
-
puts 'No error logs on the client side (Ruby).'
|
|
60
|
-
else
|
|
61
|
-
puts "#{client_status[:error_log].length} Errors (Limited to 50):"
|
|
62
|
-
puts " #{client_status[:error_log].reverse.join("\n ")}"
|
|
63
|
-
end
|
|
64
|
-
puts
|
|
65
57
|
puts 'How was the node bin path determined:'
|
|
66
58
|
configs.instance_variable_get(:@node_bin_path_log).each_with_index do |line, index|
|
|
67
59
|
puts " #{index + 1} #{line}"
|
|
@@ -78,7 +70,7 @@ namespace :svelte_on_rails do
|
|
|
78
70
|
|
|
79
71
|
namespace :ssr_client do
|
|
80
72
|
|
|
81
|
-
desc 'For development: to simulate when a client did not start on deploy (Then, on the first request of a svelte component - if not cached! - it must start)'
|
|
73
|
+
desc 'For development(and only ONE WORKER! for multiple puma workers it doesnt work!): to simulate when a client did not start on deploy (Then, on the first request of a svelte component - if not cached! - it must start)'
|
|
82
74
|
task :stop do
|
|
83
75
|
r = get_from_ssr_client(:stop)
|
|
84
76
|
if r['success']
|