diff --git a/systemd_notifier.rb b/systemd_notifier.rb index 995ab33..ad14e3e 100644 --- a/systemd_notifier.rb +++ b/systemd_notifier.rb @@ -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