Re: Reload simple

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andy Pieters <systemd@xxxxxxxxxxxxxxxxx> writes:

> Is there a good way to send a usr1 signal upon reload of a service
> with type=simple?
>
> I don't really want to do KILL USR1 $(pidof process) as that could
> pull other processes with similar names / instances.

Use $MAINPID as per man systemd.service:

ExecReload=
    Commands to execute to trigger a configuration reload in the service. This argument takes
    multiple command lines, following the same scheme as described for ExecStart= above. Use
    of this setting is optional. Specifier and environment variable substitution is supported
    here following the same scheme as for ExecStart=.

    One additional, special environment variable is set: if known, $MAINPID is set to the
    main process of the daemon, and may be used for command lines like the following:

        ExecReload=kill -HUP $MAINPID

    Note however that reloading a daemon by sending a signal (as with the example line above)
    is usually not a good choice, because this is an asynchronous operation and hence not
    suitable to order reloads of multiple services against each other. It is strongly
    recommended to set ExecReload= to a command that not only triggers a configuration reload
    of the daemon, but also synchronously waits for it to complete. For example, dbus-
    broker(1) uses the following:

        ExecReload=busctl call org.freedesktop.DBus \
                /org/freedesktop/DBus org.freedesktop.DBus \
                ReloadConfig
-- 
Feri.



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux