wiki:systemd_user_service
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
wiki:systemd_user_service [2021/06/29 12:46] – created antisa | wiki:systemd_user_service [2023/04/20 20:15] (current) – [systemd user service] edit systemd directory antisa | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== systemd user service ====== | ====== systemd user service ====== | ||
- | 1. Create user service in user's home directory ex. ///home/debian/ | + | 1. Create user service in user's home directory ex. ///home/< |
Example: | Example: | ||
- | < | + | < |
[Unit] | [Unit] | ||
Description=my npm app | Description=my npm app | ||
Line 13: | Line 13: | ||
ExecStart=/ | ExecStart=/ | ||
WorkingDirectory=/ | WorkingDirectory=/ | ||
+ | Restart=on-failure | ||
[Install] | [Install] | ||
Line 18: | Line 19: | ||
</ | </ | ||
- | 2. From root enable lingering so that it persists over reboots and logouts | + | 2. Enable service |
+ | systemctl --user enable mynpmapp.service | ||
+ | |||
+ | 3. From root enable lingering so that it persists over reboots and logouts | ||
loginctl enable-linger username | loginctl enable-linger username | ||
- | 3. Use '' | + | 4. Use '' |
===== TROUBLESHOOTING ===== | ===== TROUBLESHOOTING ===== | ||
+ | <WRAP center round info 60%> | ||
+ | Below is only needed if you switch to the user from root or another user on the system. If you login via ssh as a user, PAM subsystem will set up the required variables. | ||
+ | </ | ||
+ | |||
==== systemd --user does not work: ' | ==== systemd --user does not work: ' | ||
Line 34: | Line 42: | ||
export DBUS_SESSION_BUS_ADDRESS=" | export DBUS_SESSION_BUS_ADDRESS=" | ||
- | then logout and login again. | + | then logout and login again. If its still not working and you get na error |
+ | |||
+ | Failed to connect to bus: No such file or directory | ||
+ | |||
+ | try rebooting the server. | ||
Line 45: | Line 57: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
wiki/systemd_user_service.1624970778.txt.gz · Last modified: 2021/06/29 12:46 by antisa