You are not logged in.

#1 2018-10-02 08:52:26

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Ways of launch D-Bus

I start VNC server on boot with systemd unit

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=user1
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStartPre=/bin/dbus-launch
ExecStart=/usr/bin/vncserver %i -alwaysshared -fg
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target

If I try to add Requires=dbus.service in [Unit] section instead of ExecStartPre=/bin/dbus-launch in [Service] section I get Xfce socket error when connect to VNC server. Result is the same if I create separate service for dbus-launch like

[Unit]
Description=D-Bus startup for VNC server

[Service]
Type=simple
User=user1
ExecStart=/bin/dbus-launch

and add this service in Requires filed of VNC server unit.
Get the same result if start dbus-launch not from systemd service unit but from .xstartup file of VNC srever.
Question is why D-Bus starts one way when it is launched in ExecStartPre field of VNC server unit and another way when is launched from separate service unit or .xstartup file?

Last edited by Kirill Bugaev (2018-10-02 11:11:26)

Offline

#2 2018-10-02 13:48:36

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,541
Website

Re: Ways of launch D-Bus

man systemd.service wrote:

ExecStart= commands are only run after all ExecStartPre= commands that were not prefixed with a "-" exit successfully.

Adding a Requires entry is not equivalent.  Including Requires and After likely will be sufficient, but the proper way is listed in the man page as well:

man systemd.service wrote:

Services with Type=dbus set automatically acquire dependencies of type Requires= and After= on dbus.socket

Last edited by Trilby (2018-10-02 13:49:54)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2018-10-02 15:49:37

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: Ways of launch D-Bus

Trilby wrote:

Adding a Requires entry is not equivalent.  Including Requires and After likely will be sufficient,

I had tried add After entry with Requires, but result is the same.

Trilby wrote:

but the proper way is listed in the man page as well:

man systemd.service wrote:

Services with Type=dbus set automatically acquire dependencies of type Requires= and After= on dbus.socket

When I change type of VNC server unit to Type=dbus "systemctl status vncserver@:1" show

...
Loaded: bad-setting (Reason: Unit vncserver@:1.service has a bad unit file setting.)
...

May be I need to specify BusName, but I don't know how.

Offline

Board footer

Powered by FluxBB