'start-stop-daemon --start --background --make-pidfile --pidfile /run/name.pid --chroot /chroots/' creates pidfile in '/chroots/run/name.pid', but '/run/openrc/daemons/name/001' is created with 'pidfile=/run/name.pid' line instead of 'pidfile=/chroots/run/name.pid'. rc-status and start-stop-daemon do not see such pidfile, so they detect service as not running. Please either add 'chroot=' variable to '/run/openrc/daemons/name/001' or add to 'pidfile=' var. I think it is more correct to add 'chroot=' as separate variable instead of including in other. May be it would be better to add _all_ start-stop-daemon cli options as variables to /run/openrc/daemons/*/*, just in case.
I don't see a reason to use the chroot path here as it's OpenRC that gets the --pidfile option, not the daemon itself.
Now openrc has _very_ bad support for chroot, it even is using different paths during start and during status actions: during start it is $(path from --chroot)$(path from --pidfile) and during status it is just $(path from --pidfile), so after start any service is detected as not running when --make-pidfile is used. For better understanding try to provide example of openrc script which uses 'start-stop-daemon --make-pidfile --chroot /somepath --pidfile /run/openrc-bug.pid' - you will reproduce the bug. Or do you need more info?
Hi, I can confirm the problem. Here is a short description, when service is runing in a chroot it creates a pidfile in ${chroot}/run/$serive.pid. And in /run/daemon/$service/000 there is information that pidfile is stored in /run/$service.pid, as a result openrc fails to check status. Two mentioned solutions may work and I'm attaching both of them.
Created attachment 386972 [details, diff] Solution based on storing of s-s-d arguments This is a proof of concept (however works as a workaround for this bug). The idea is to save chroot option usgin rc_service_value_set, so both s-s-d and rc-status will be aware of chrooted service. git url: https://github.com/qnikst/openrc/tree/bug-524388-2
Created attachment 386974 [details, diff] Solution based on writing modified pidfile Solution based on the storing of pid with known chroot, it looks like more hairy for me
A fix for this has been implemented in these commits: f9acd65 8c7ea4e This will be in OpenRC-0.14 and OpenRC-0.13.2.
The fix is to add a chroot variable which will need to be set to the chroot path in a service script. This variable is used in the default start and stop functions. This is also saved the same way pidfile and the other variables are saved.