View previous topic :: View next topic |
Author |
Message |
erg_samowzbudnik Apprentice


Joined: 09 Sep 2011 Posts: 229 Location: European sticks
|
Posted: Wed Nov 27, 2024 11:54 am Post subject: openrc service not cleaning up |
|
|
Hi.
Problem:
openrc service is not cleaning up.
In the documentation it actually says that it wont: Quote: | When stopping we only stop the first pid listed in the pidfile. |
Description of the issue:
I have created a script in /etc/init.d with:
Code: | #!/sbin/openrc-run
supervisor=supervise-daemon
command="/usr/local/bin/fancy_service.sh"
pidfile="/run/${RC_SVCNAME}.pid"
command_args="--no-daemon -p ${pidfile}"
command_background=True |
and a script fancy_service.sh in /usr/local/bin :
Code: | #!/bin/bash
cd /var/www/fancy_service || exit
python main.py |
Now, the pid file that openrc knows about is the fancy_service.sh PID, not the child.
Should I just trap and handle signal in the fancy_service.sh or is there a more standard way to go about it? |
|
Back to top |
|
 |
erg_samowzbudnik Apprentice


Joined: 09 Sep 2011 Posts: 229 Location: European sticks
|
Posted: Wed Nov 27, 2024 12:10 pm Post subject: |
|
|
Easy:
exec python main.py
and it all works as expected. |
|
Back to top |
|
 |
grknight Retired Dev

Joined: 20 Feb 2015 Posts: 2028
|
Posted: Wed Nov 27, 2024 1:51 pm Post subject: Re: openrc service not cleaning up |
|
|
erg_samowzbudnik wrote: | Code: | #!/sbin/openrc-run
supervisor=supervise-daemon
command="/usr/local/bin/fancy_service.sh"
pidfile="/run/${RC_SVCNAME}.pid"
command_args="--no-daemon -p ${pidfile}"
command_background=True |
|
One thing to note here is that "-p ${pidfile}" as an argument might want to be avoided if the service is creating a pidfile with this option when combined with command_background=True. The latter will also create and write the PID when used with start-stop-daemon.
Also, when using supervise-daemon, having the service create the pidfile will be wrong. supervise-daemon expects the pidfile to be of itself, not the service. |
|
Back to top |
|
 |
|