diff --git a/README b/README index d46280b..a72077b 100644 --- a/README +++ b/README @@ -81,7 +81,9 @@ Enter the following line to manually connect to your server: client.connect : ----- Prepare for automatic startup +---- Prepare for automatic startup as a system service: +(alternatively, see USER.txt) + Create a copy of the service file and adjust it with your script name # cp rust.service rustmyserver.service diff --git a/USER.txt b/USER.txt new file mode 100644 index 0000000..02435e2 --- /dev/null +++ b/USER.txt @@ -0,0 +1,33 @@ +You can also run the rust daemon as a user own process. +This means, that the user itself is able to start/stop the instance without sudo rights. + +Usually user services are started during the first login and stopped when +then last session closes. To prevent this, make the user session available during bootup + + + # su + # loginctl enable-linger rust + # exit + +Create a copy of the service file and adjust it with your script name, +also remove the user & group parameter and change the Wanted By Target: + + # cp rust.service rustmyserver.service + # sed -i -e 's|User=rust||' -e 's|Group=rust||' rustmyserver.service + # sed -i -e 's|multi-user.target|default.target|' rustmyserver.service + # nano rustmyserver.service + +Copy the service file to the systemd user folder: + + # mkdir -p ~/.config/systemd/user/ + # cp rustmyserver.service ~/.config/systemd/user/ + +To enable the Userservice rustmyserver.service for startup run: + + # systemctl --user enable rustmyserver.service + +To start/stop it use: + + # systemctl --user start rustmyserver.service + +