Fixing socket type bug.

This commit is contained in:
2026-06-08 08:10:18 +08:00
parent 8fc6c38797
commit 57a157bad7
+5 -1
View File
@@ -27,7 +27,11 @@ class SystemdNotifier
else
MethodExecutor.record("debug", "heartbeat", "Found NOTIFY_SOCKET, enabling heartbeat")
@enable_heartbeat = true
@socket = UNIXSocket.new(@notify_socket)
# 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")
end