Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
openrc service not cleaning up
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 228
Location: European sticks

PostPosted: Wed Nov 27, 2024 11:54 am    Post subject: openrc service not cleaning up Reply with quote

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
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 228
Location: European sticks

PostPosted: Wed Nov 27, 2024 12:10 pm    Post subject: Reply with quote

Easy:

exec python main.py

and it all works as expected.
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1960

PostPosted: Wed Nov 27, 2024 1:51 pm    Post subject: Re: openrc service not cleaning up Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum