Re: [systemd-devel] type=notify not working as intended
On Di, 15.08.17 09:29, Kalpa Gunarathna (ka...@sigscale.com) wrote: > Hello all, > > I have scripted a service unit as follow. > > [Unit] > Description="A test service" > After=epmd.service epmd.socket > > [Service] > ExecStart=/home/otpuser/bin/start > Type=notify > NotifyAccess=all > WorkingDirectory=~ > User=otpuser > Group=otp > Restart=always > RestartSec=3 > > [Install] > WantedBy=multi-user.target > > > ExecStart directs to a shell script which starts a Erlang run_erl daemon. > This daemon is forking a process which is the BEAM virtual machine. In the > forked process Im sending "READY=1\nSTATUS=Initialized\nMAINPID=" > <> "\n to systemd via sd_notify. The problem is service > is getting restarted constantly. When you use Type=notify, then the main process of the daemon defines the runtime of your service. That means you probably want to use the shell's "exec" command to replace the shell script with your erlang daemon. if you instead just fork it off, and exit in the shell script, then systemd will notice that it exited and will consider the service dead. > journalctl give this > > abc.service: Service hold-off time over, scheduling restart. > Stopped "A test service.". > > > Is it required to send READY=1 from the daemon it self ? or can systemd > allow forked process of the daemon to send REDAY=1 notification? It needs to come from any process that is witelisted using NotifyAccess=. Note though that there's a bit of a race: if you send READY=1 and immediately exit from the process doing that, then systemd can't properly relate the message to the service (that's a race we can#t fix without kernel support), except if the process is actually the one systemd forked off. Hence, sd_notify(READY=1) works reliably only if either: 1. it is invoked by the immediate process systemd forked off or 2. the process is long-running and stays around for longer after sending READY=1 Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] type=notify not working as intended
On Tue, Aug 15, 2017 at 5:59 AM, Kalpa Gunarathnawrote: > Hello all, > > I have scripted a service unit as follow. > > [Unit] > Description="A test service" > After=epmd.service epmd.socket > > [Service] > ExecStart=/home/otpuser/bin/start > Type=notify > NotifyAccess=all > WorkingDirectory=~ > User=otpuser > Group=otp > Restart=always > RestartSec=3 > > [Install] > WantedBy=multi-user.target > > > ExecStart directs to a shell script which starts a Erlang run_erl daemon. > This daemon is forking a process which is the BEAM virtual machine. In the > forked process Im sending "READY=1\nSTATUS=Initialized\nMAINPID=" > <> "\n to systemd via sd_notify. The problem is service > is getting restarted constantly. > > journalctl give this > > abc.service: Service hold-off time over, scheduling restart. > Stopped "A test service.". > > > Is it required to send READY=1 from the daemon it self ? or can systemd > allow forked process of the daemon to send REDAY=1 notification? > > It works when Type=forking and PIDFile is specified, but can we have > Type=forking and without PIDFIle, notify READY=1 via forked process ? > > My systemd version > > $ systemd --version > systemd 229 > The service fails when the main process terminates before a READY=1 notification is received. Contrary to Reindl Haralds claim, this notification is allowed to come from whatever process that is allowed to send notifications, as controlled by NotifyAccess=. In order to not give up on the service when the main process terminates, but wait for the remaining processes in the cgroup, you should add RemainAfterExit=yes to your unit. Regards, - Jouke ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] type=notify not working as intended
Am 15.08.2017 um 05:59 schrieb Kalpa Gunarathna: Hello all, I have scripted a service unit as follow. [Unit] Description="A test service" After=epmd.service epmd.socket [Service] ExecStart=/home/otpuser/bin/start Type=notify NotifyAccess=all WorkingDirectory=~ User=otpuser Group=otp Restart=always RestartSec=3 [Install] WantedBy=multi-user.target ExecStart directs to a shell script which starts a Erlang run_erl daemon. This daemon is forking a process which is the BEAM virtual machine. In the forked process Im sending "READY=1\nSTATUS=Initialized\nMAINPID=" <> "\n to systemd via sd_notify. The problem is service is getting restarted constantly MAINPID is supposed to send the notify Type=notify needs to be explicit supported by the daemon ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] type=notify not working as intended
Hello all, I have scripted a service unit as follow. [Unit] Description="A test service" After=epmd.service epmd.socket [Service] ExecStart=/home/otpuser/bin/start Type=notify NotifyAccess=all WorkingDirectory=~ User=otpuser Group=otp Restart=always RestartSec=3 [Install] WantedBy=multi-user.target ExecStart directs to a shell script which starts a Erlang run_erl daemon. This daemon is forking a process which is the BEAM virtual machine. In the forked process Im sending "READY=1\nSTATUS=Initialized\nMAINPID=" <> "\n to systemd via sd_notify. The problem is service is getting restarted constantly. journalctl give this abc.service: Service hold-off time over, scheduling restart. Stopped "A test service.". Is it required to send READY=1 from the daemon it self ? or can systemd allow forked process of the daemon to send REDAY=1 notification? It works when Type=forking and PIDFile is specified, but can we have Type=forking and without PIDFIle, notify READY=1 via forked process ? My systemd version $ systemd --version systemd 229 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel