You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The systemd units provided by pat are installed on the system level (and require sudo for administration). Have you considered using "user units" instead? Systemd runs a system service manager as root, but it also runs a user service manager for each active user (more on that below). For inspiration, Syncthing provide both system and user units (presumably for convenience).
The system and user unit files would be almost identical. The only difference is that:
the user unit does not need any template parameter
the user unit does not need the User=%i line
WantedBy=default.target is used instead of multi-user.target
You used sudo systemctl ... for system units and systemctl --user ... for user units (no sudo)
The unit file is stored in /usr/lib/systemd/user/pat.service instead of /lib/systemd/system/[email protected]
If you have Syncthing installed, you can take a look yourself using systemctl cat syncthing@ and systemctl --user cat syncthing.
One caveat is that the default behavior of systemd is to shut down the user service manager (and all its services) when the user logs out. It is also not started when the computer boots. This can be changed with configuration, however. Just run this command once:
sudo loginctl enable-linger $USER
When "linger" is active for the user, its service manager is tarted on boot and will remain running even if the user is logged out. This is great for servers.
What do you think? I can make the code changes and a pull request if thou think this is a good idea.
The text was updated successfully, but these errors were encountered:
raek
changed the title
systemd: Procide user units alongside the system units
Improvement suggestion for systemd units: Provide user units alongside the system units
Sep 24, 2024
Hmm. I don't know how this would interplay with the ax25 service (which I assume has to run as root?). I'm not aware of any way of making the pat.service user unit depend on the ax25.service system unit (since they run in different service managers / "systemd instances").
The systemd units provided by
pat
are installed on the system level (and require sudo for administration). Have you considered using "user units" instead? Systemd runs a system service manager as root, but it also runs a user service manager for each active user (more on that below). For inspiration, Syncthing provide both system and user units (presumably for convenience).The system and user unit files would be almost identical. The only difference is that:
User=%i
lineWantedBy=default.target
is used instead ofmulti-user.target
sudo systemctl ...
for system units andsystemctl --user ...
for user units (no sudo)/usr/lib/systemd/user/pat.service
instead of/lib/systemd/system/[email protected]
If you have Syncthing installed, you can take a look yourself using
systemctl cat syncthing@
andsystemctl --user cat syncthing
.One caveat is that the default behavior of systemd is to shut down the user service manager (and all its services) when the user logs out. It is also not started when the computer boots. This can be changed with configuration, however. Just run this command once:
When "linger" is active for the user, its service manager is tarted on boot and will remain running even if the user is logged out. This is great for servers.
What do you think? I can make the code changes and a pull request if thou think this is a good idea.
The text was updated successfully, but these errors were encountered: