Open PradeepKiruvale opened 2 years ago
Hello! You're using Type=notify
, right?
I don't know what might be causing this, but it's an interesting problem since it involves the interaction between two different features. How are you enabling the watchdog, using WatchdogSec
in the service file, or using the Watchdog
notification?
I was not using Type=notify
because the service start was hanging. I am using WatchdogSec
to enable the watchdog feature. Also, I noticed from the documentation that sd_notify
crate does not support sending notifications on behalf of another process. So, I feel it does not work for my use case.
does not support sending notifications on behalf of another process
I wrote that a couple of years ago, I wonder what I meant :sweat_smile:. But MAINPID
is not a notification on behalf of another process. It's a notification telling systemd
to watch a different process instead of the current one.
And if you don't use Type=notify
, I don't know if notifications do anything..
does not support sending notifications on behalf of another process
I wrote that a couple of years ago, I wonder what I meant 😅. But
MAINPID
is not a notification on behalf of another process. It's a notification tellingsystemd
to watch a different process instead of the current one.
Ok, that means I can use these API's to send the notification on behalf of another process. Good to know that. But as I understand the sd-notification
feature, the systemd
creates a socket to communicate between the service it starts and systemd. Will it be possible to use the same socket endpoint to send the message on behalf of another service?. I read that its possible, provided if there are enough privileges
. But how to set these privileges in the service file to allow another process to send the notification.
And if you don't use
Type=notify
, I don't know if notifications do anything..
Ok, I did not use because there is no way to tell the systemd that the ready
state of a process using PID. So, the systemd hangs there till it receives the notification telling it's ready.
Ok, that means I can use these API's to send the notification on behalf of another process. Good to know that.
You can't, because the docs say it's not supported. I was just saying that MAINPID
is sent on behalf of the current, not another process.
Ok, that means I can use these API's to send the notification on behalf of another process. Good to know that.
You can't, because the docs say it's not supported. I was just saying that
MAINPID
is sent on behalf of the current, not another process.
Ha ok, thanks for the clarification.
Yeah, so see sd_pid_notify
, that's what I meant there.
Yeah, so see
sd_pid_notify
, that's what I meant there.
Yup, had a look. Needed some Rust crate that supports this. I mean pure Rust crate :).
Well, we can implement it, but I wasn't sure about how the API should look (notify(Some(pid), ...)
vs. notify_pid(pid, ...)
).
I feel to be in line with C
APIs we can implement notify
and notify_pid
as two separate APIs.
So I just have to figure out how to send the PID...
One thing I learned is that I needed to set NotifyAccess=all
so my child process was able to notify over the socket.
Hi,
I am using this crate for sending the
notifications
tosystemd
on behalf of another process. Below is my code snippet that is used for sending the notification. I collect theprocess ID
of the process to be monitored by thewatchdog
program and send the notification to the systemd on behalf of that process. The code runs fine, without any errors. But the notifications are not reaching the system. So, thesystemd
keeps restarting the service afterwatchdog timeout
. Please help me am I doing the right thing here or not.fn notify_systemd(pid: u32) {
Thanks, Pradeep