You are not logged in.
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
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
Do you know how to autostart the service without any login using the configuration you suggested?
Offline
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
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