svclean-shutdown command permanently shuts down all
services and loggers found in the given directory. (Loggers are not
shut down until their corresponding services are down.) It creates
the file "
svclean/shutdown" in each service and
to take the service down and exit. When
supervise wrapper will notice the
svclean/shutdown" file and exit without
supervise, so the filesystem(s) containing the
service directories can be unmounted or remounted read-only.
svclean-shutdown takes a few seconds to run - in the
current version, typically around 9 seconds - to make sure all
services are really down. If it takes much longer, you may have a
service that doesn't exit when it receives
can find and kill such services while
running; it will exit when all services are down.
svclean-shutdown exits 0, the
intended guarantees are:
supervises are down and will not be restarted.
down" file. There is also a corner case where a
superviseprocess might be killed while its service remains up, and
svclean-shutdownwould consider it successfully shut down.)
Unfortunately, there is a race condition that can result in services still being up after svclean-shutdown exits 0, but it requires that a ready-to-run process be overlooked by the kernel scheduler for a full second:
svclean/shutdownfile, so it
supervisefor a while.
svclean-shutdownsleeps for a second, to try to avoid this race condition.
svclean-shutdowntries to do "
svc -dx", but can't open the control pipe, and thus concludes that there is no
superviserunning and that the service is permanently down.
supervise, which only now opens the control pipe to listen for commands.
I think complete, certain reliability would require patching svscan.
svclean-shutdownwithout the wrappers
svclean-shutdown can be used to shut down services that
are not running under svclean's wrappers. Only the wrappers will
supervises from being restarted, but
svclean-shutdown is still useful to shut down services
svscan is no longer running. Beware that without
the wrappers, some logs may be lost; it's impossible to tell with
certainty whether the log pipe is empty without having an open
descriptor for the pipe. However,
leaves the logger running for at least a second after the service is
down, so the risk of losing logs when the wrappers are not in use is
not too great. If you do not use the wrappers, it is recommended that
you start the loggers for all services that have been up before
svclean-shutdown; if a service was running
previously, but the logger was stopped before it wrote all the logs,
the logs may be lost.