release: 发布版本 60176fa,RuboCop 零告警,网页新增版本号展示

This commit is contained in:
2026-06-08 11:47:00 +08:00
parent 60176fa316
commit 8cd942be2d
9 changed files with 171 additions and 140 deletions
+15 -13
View File
@@ -14,25 +14,27 @@
# frozen_string_literal: true
# Sends keep-alive notifications (including WATCHDOG=1) to systemd
# via the NOTIFY_SOCKET datagram socket, enabling service supervision.
class SystemdNotifier
require_relative 'method_executor'
public
@notify_socket = ENV["NOTIFY_SOCKET"]
@watchdog_usec = (ENV["WATCHDOG_USEC"] || '0').to_i
unless @notify_socket && File.socket?(@notify_socket)
MethodExecutor.record("error", "heartbeat", "NOTIFY_SOCKET is not set or is not a socket, am I a service?")
@enable_heartbeat = false
else
MethodExecutor.record("debug", "heartbeat", "Found NOTIFY_SOCKET, enabling heartbeat")
@notify_socket = ENV.fetch('NOTIFY_SOCKET', nil)
@watchdog_usec = (ENV['WATCHDOG_USEC'] || '0').to_i
if @notify_socket && File.socket?(@notify_socket)
MethodExecutor.record('debug', 'heartbeat', 'Found NOTIFY_SOCKET, enabling heartbeat')
@enable_heartbeat = true
# Fix(2026-06-08): 将 UNIXSocket(SOCK_STREAM) 改为 SOCK_DGRAM
# systemd NOTIFY_SOCKET 是 datagram socket,用 stream socket 连接会报
# Protocol wrong type for socket (Errno::EPROTOTYPE)
@socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM)
@socket.connect(Socket.pack_sockaddr_un(@notify_socket))
MethodExecutor.record("debug", "heartbeat", "Heartbeat socket opened")
MethodExecutor.record('debug', 'heartbeat', 'Heartbeat socket opened')
else
MethodExecutor.record('error', 'heartbeat', 'NOTIFY_SOCKET is not set or is not a socket, am I a service?')
@enable_heartbeat = false
end
# @return [Boolean]
@@ -44,13 +46,13 @@ class SystemdNotifier
# @return [void]
def self.notify(message)
return unless @enable_heartbeat
begin
@socket.send(message, 0)
MethodExecutor.record("debug", "heartbeat", "Heartbeat sent: #{message}")
rescue => e
MethodExecutor.record("error", "heartbeat", "Failed to send heartbeat: #{e}")
MethodExecutor.record('debug', 'heartbeat', "Heartbeat sent: #{message}")
rescue StandardError => e
MethodExecutor.record('error', 'heartbeat', "Failed to send heartbeat: #{e}")
@enable_heartbeat = false
end
end
end