[systemd-devel] Service with alternative configuration

Marv Lelgemann 144dbspl at gmail.com
Sat Mar 9 09:44:40 UTC 2019


If anyone should be faced with a similar issue, i solved it by setting and
unsetting a systemd environment variable (e.g. SERVICE_FOO_OPTARGS)
referenced from ExecStart of the service' unit file and then restarting the
service. On DBus there are SetEnvironment and UnsetEnvironment methods, or
set-environment and unset-environment commands when using systemctl.

Am Do., 7. März 2019 um 14:03 Uhr schrieb Marv Lelgemann <144dbspl at gmail.com
>:

> I have a systemd service unit of type "dbus". I would like to have the
> option to restart (or stop and start) the service with additional command
> line arguments in "ExecStart".
>
> I tried using a template unit with "EnvironmentFile" selected by the
> instance name. I also tried a template unit with drop-in configuration
> files which override the "ExecStart". Both approaches somehow worked but
> led to a problem sooner or later when the default instance was enabled in
> my default target. The error message is "Two services allocated for the
> same bus name" when trying to start the non-default service, even if no
> other instance is started. Using "Conflicts" in the unit file also didn't
> help.
>
> What I essentially want to achieve is to restart a running service with
> another set of command line arguments (non-persistent). I want to do this
> preferably over systemd's DBus API from within my application. I tried
> using org.freedesktop.systemd1.Manager.SetUnitProperties to update
> EnvironmentFile but this didn't work.
>
> Any ideas on how to achieve this?
>
> -Marv
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190309/3d278db3/attachment.html>


More information about the systemd-devel mailing list