From 335332f73bcd6503c16b2235302c79a5997294b4 Mon Sep 17 00:00:00 2001 From: noah <61599590+lingawakad@users.noreply.github.com> Date: Mon, 11 Sep 2023 13:30:32 -0400 Subject: [PATCH] Update DEVELOPMENT.md Updated systemd config with recommendations from https://github.com/geoffwhittington/meshtastic-matrix-relay/pull/57#pullrequestreview-1620383106 --- DEVELOPMENT.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5ad98bf..b36665c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -85,19 +85,26 @@ INFO:meshtastic.matrix.relay:Sent inbound radio message to matrix room: #someroo ``` ## Persistence -If you'd like the bridge to run automatically on startup in Linux, you can set up a systemd service. +If you'd like the bridge to run automatically (and persistently) on startup in Linux, you can set up a systemd service. +In this example, it is assumed that you have the project a (non-root) user's home directory, and set up the venv according to the above. + +Create the file ```~/.config/systemd/user/mmrelay.service```: ``` [Unit] Description=A Meshtastic to [matrix] bridge -After=multi-user.target +After=default.target [Service] Type=idle - -WorkingDirectory=/home/$USER/meshtastic-matrix-relay -ExecStart=/home/$USER/meshtastic-matrix-relay/.pyenv/bin/python /home/$USER/meshtastic-matrix-relay/main.py +WorkingDirectory=%h/meshtastic-matrix-relay +ExecStart=%h/meshtastic-matrix-relay/.pyenv/bin/python %h/meshtastic-matrix-relay/main.py +Restart=on-failure [Install] -WantedBy=multi-user.target +WantedBy=default.target +``` +The service is enabled and started by +``` +$ systemctl --user enable mmrelay.service +$ systemctl --user start mmrelay.service ``` -In this example, it is assumed that you cloned the git repo into a user's home directory, and set up the venv according to the above.