[systemd-devel] How to create a systemd service?

Kai Krakow hurikhan77 at gmail.com
Sat Dec 20 09:51:37 PST 2014


jenia.ivlev <jenia.ivlev at gmail.com> schrieb:

> I want to start synapse (its a program that allows to run programs more
> easily) at login using systemd. So I created this systemd-service config
> file:
> 
>     [Unit]
>     Description=Syanpse start up
>     After=lxdm.service
> 
>     [Service]
>     User=jenia
>     ExecStart=/usr/bin/synapse
> 
>     [Install]
>     WantedBy=multi-user.target
> 
> I doesnt work neither automatically, nor by calling
> /usr/lib/systemd/system/synapse.service as so:
>     systemctl start synapse
> 
> It tells me:
> 
>     ● synapse.service - Syanpse start up
>        Loaded: loaded (/usr/lib/systemd/system/synapse.service; enabled)
>        Active: failed (Result: exit-code) since Tue 2014-12-16 21:23:11
>        EST; 8min ago
>       Process: 8545 ExecStart=/usr/bin/synapse (code=exited,
>       status=1/FAILURE)
>      Main PID: 8545 (code=exited, status=1/FAILURE)
>     
>     Dec 16 21:23:11 station1 systemd[1]: Started Syanpse start up.
>     Dec 16 21:23:11 station1 synapse[8545]: [02:23:11.039206 Info]
>     Starting up... Dec 16 21:23:11 station1 synapse[8545]:
>     [02:23:11.040620 Gtk-Warning] cannot open display: Dec 16 21:23:11
>     station1 systemd[1]: synapse.service: main process exited,
>     code=exited, status=1/FAILURE Dec 16 21:23:11 station1 systemd[1]:
>     Unit synapse.service entered failed state. Dec 16 21:23:11 station1
>     systemd[1]: synapse.service failed.

The error say "cannot open display".

> How do I make this work, can someone please tell me?

You cannot run synapse as a system service. It's an X client which needs 
access to your X session after you logged in. I'm not sure if it could be 
solved by using systemd in "--user" mode but probably at least not now. 
There are afforts to use systemd in user mode to spawn the xsession of the 
user and use it as session manager, i.e. in KDE. But currently this does not 
work well enough to not be complicated.

So I suggest sticking synapse into your session autostart like so (as a 
user, not root):

$ ln -snf $(which synapse) $HOME/.config/autostart/

Then logout and in again.

-- 
Replies to list only preferred.



More information about the systemd-devel mailing list