You are not logged in.

#1 2018-03-30 12:41:41

qualphey
Member
Registered: 2018-03-30
Posts: 3

How do I setup user autostart and properly configure systemd user serv

On my arch server, I was setting up users restricted to their home directories. I ran:

useradd -m -s /bin/bash username

and

passwd username

I've read this wiki article...

I figured I should use systemd user services to make each user run a node server on startup. So i logged into one user account su username and created a file

~/.config/systemd/user/serve.service

containing:

[Unit]
Description=One of the servers

[Service]
ExecStart=/usr/bin/node /home/username/server.js

[Install]
WantedBy=default.target

then I ran

systemctl --user enable serve.service

which responded with

Failed to connect to bus: Permission denied

As far as I understand I should run systemctl --user ... command logged in as a user and not as root.

So what did I miss in this configuration?

Offline

#2 2018-03-30 13:32:43

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,853

Re: How do I setup user autostart and properly configure systemd user serv

su does not log in, therefore it does not create the systemd user instance.

But there's a much better solution which even works for users created later... install the service to the system user folder "/etc/systemd/user/" then use systemctl --global enable .... to enable the user service automatically for all users.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#3 2018-04-04 16:33:15

qualphey
Member
Registered: 2018-03-30
Posts: 3

Re: How do I setup user autostart and properly configure systemd user serv

Do you know how to autostart the service without any login using the configuration you suggested?

Offline

#4 2018-04-05 04:50:36

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,853

Re: How do I setup user autostart and properly configure systemd user serv


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2019-01-09 00:13:35

qualphey
Member
Registered: 2018-03-30
Posts: 3

Re: How do I setup user autostart and properly configure systemd user serv

I've managed to fix the error:

Failed to connect to bus: Permission denied

by running

loginctl enable-linger username

and adding

DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus

to

/home/username/.bashrc

Offline

Board footer

Powered by FluxBB