[systemd-devel] PATCH: handle SYSTEMCTL_OPTIONS in systemctl
Frederic Crozat
fcrozat at suse.com
Wed Jan 16 09:15:28 PST 2013
Le mercredi 16 janvier 2013 à 16:58 +0000, Colin Guthrie a écrit :
> 'Twas brillig, and Frederic Crozat at 16/01/13 16:34 did gyre and gimble:
> > Hi,
> >
> > on openSUSE, we found the need to sometime force "--ignore-dependencies"
> > when systemctl is called (usually from other services / initscripts /
> > tools started by initscripts and which can cause deadlock).
> >
> > To handle this in a transparent manner, I'd like to introduce
> > SYSTEMCTL_OPTIONS environment variable, which, if set, would cause
> > systemctl to append its contents as if it was specified on command line.
>
> Most common use case for this is using the --no-block and
> --ignore-dependancies options. I found a need for this to prevent
> deadlocks when certainly early packages (e.g. mandriva_everytime (if you
> can remember back that far to your mdv days) which would do various h/w
> fu (much of it outdated these days tho') and even start some services.
> As this was done early in boot the starting of those services could
> block in systemd - hence the need to use --no-block)
>
> IIRC this is handled in the redhat "initscripts" (used also on Mageia -
> dunno about suse...)
>
>
> e.g. see this from /etc/init.d/functions (possibly a bit out of date and
> IIRC slightly patched by me for Mageia too (the NO_BLOCK option)):
>
> systemctl_redirect () {
> local s
> local prog=${1##*/}
> local command=$2
> local options=""
>
> case "$command" in
> start)
> s=`gprintf "Starting %s (via systemctl): " $prog`
> ;;
> stop)
> s=`gprintf "Stopping %s (via systemctl): " $prog`
> ;;
> reload|try-reload)
> s=`gprintf "Reloading %s configuration (via systemctl):
> " $prog`
> ;;
> restart|try-restart|condrestart)
> s=`gprintf "Restarting %s (via systemctl): " $prog`
> ;;
> esac
>
> if [ -n "$SYSTEMCTL_IGNORE_DEPENDENCIES" ] ; then
> options="$options --ignore-dependencies"
> fi
> if [ -n "$SYSTEMCTL_NO_BLOCK" ] ; then
> options="$options --no-block"
Yes, we have a similar patch in /etc/rc.status on openSUSE, which is
using SYSTEMCTL_OPTIONS as variable name. So far, I haven't found a case
where --no-block was needed, only "--ignore-dependencies" was needed
(which is why I used a catch-all variable name, just in case
"--no-block" would be needed later, so we wouldn't need to release
another version of the package shipping /etc/rc.status).
But it is no longer enough because we started to migrate some
initscripts to systemd unit and our YaST tools have also learned to call
systemctl to start / stop services. And because of that, the
"workaround" in /etc/rc.status is no longer effective. And YaST team
doesn't handle to handle the "SYSTEMCTL_OPTIONS" workaround in their
generic service handling code (I can understand that).
--
Frederic Crozat <fcrozat at suse.com>
SUSE
More information about the systemd-devel
mailing list