Open abchk1234 opened 7 years ago
I'd love to see this feature. I'm using stacked runlevels for this at the moment, but it is not very practical when you want multiple services to behave this way without placing them in the same runlevel
The way to do this would be to force re-calculating the deptree then resetting the runlevel every time you stop a service. By hand it would look like this:
# rc-service foo stop
# rc-update -u
# openrc
You couldn't just stop foo if only one service depending on it was stopped, because you would have to make sure there were no services depending on foo.
What do folks think, is it a good idea to do this?
In my opinion, it would add a lot of processing to stopping a service as well as making the exit code from stopping a service ambiguous. For example,
# rc-service foo stop
# echo $?
1
Does that failure mean that the service failed stopping? does it mean that we couldn't get into the runlevel, say, because some other service in the runlevel failed to start?
Thoughts?
Hmm, I had thought that this would be easy to implement: after stopping the service just call the function that gets called openrc
is run, to recalculate the tree and stop the dependent services; I did not think about the exit status part.
Service stopping is already a bit messed up in my opinion, for example if I try to stop a service that is dependent on other services and those other services get stopped due to some reason, then it fails to stop the specified service as well.
Example:
$ sudo service httpd stop
Password:
* WARNING: httpd is already stopped
$ pgrep -l httpd
11050 httpd
11052 httpd
11053 httpd
11056 httpd
$ rc-status
Runlevel: default
sysklogd [ started ]
acpid [ started ]
dbus [ started ]
NetworkManager [ inactive ]
consolekit [ started ]
netmount [ scheduled ]
tlp [ started ]
dcron [ started ]
alsasound [ started ]
local [ started ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
modules-load [ started ]
xdm-setup [ started ]
Dynamic Runlevel: manual
As can be seen above, if I try to stop httpd
when my network is down it fails to detect that it is actually running and reports it as stopped.
So it would seem that stopping a service is not so simple currently as it checks whether dependent services are running currently...
@williamh The above seems like a bug to me and I can open a separate issue for it if required.
@williamh let's say I have lte
and modem
service, lte
service has need modem
(since modem is required for both lte and gps), so when I do /etc/init.d/modem stop
it also stops lte
service. I'm not sure how the exit code behaves, but I'd say that with this feature it should behave the same as when the dependant service is stopped
Hi,
Let me illustrate the issue with an example:
When starting the
libvirtd
service, it neededvirtlogd
which got automatically started. However whenlibvirtd
was stopped,virtlogd
kept on running in the background...Had a chat about it in the IRC channel, and this can be currently achieved in two ways, via running
openrc
to re-calculate dependencies and stop extra services (manual), or by using a stacked runlevel forlibvirtd
which derives from thedefault
runlevel and switching to it when starting the service and switching back to thedefault
runlevel to stop it (automatic after creating once).To make it more convenient, could a config option be added to
/etc/rc.conf
which automatically stops dependant services when the original service has been stopped?