diff --git a/Readme.md b/Readme.md index 1d89b7e..abc400e 100644 --- a/Readme.md +++ b/Readme.md @@ -51,7 +51,75 @@ Alle 2 Sekunden wird ein JSON wie folgt gesendet: - Bei fehlender Verbindung wird automatisch reconnectet. - Fehler beim Senden werden geloggt, blockieren aber nicht den Hauptloop. -rc.local script to start LoudnessSpy on boot +## Autostart + +To set up LoudnessSpy to start automatically using systemd on Raspberry Pi OS Lite, you can create a systemd service file. Here’s how to do that: +Steps to Create a systemd Service for LoudnessSpy + + Open a Terminal: + You should already be in the terminal since you're using Raspberry Pi OS Lite. + + Create a systemd Service File: + Use the following command to create a new service file: + +```bash +sudo nano /etc/systemd/system/loudnessspy.service +``` +Add the Following Content: +In the opened file, add the following lines: + +```ini +[Unit] +Description=LoudnessSpy Service +After=network.target + +[Service] +ExecStart=/opt/loudnessspy/loudnessspy +Restart=always +User=pi +Environment=DISPLAY=:0 + +[Install] +WantedBy=multi-user.target +``` + ExecStart: This is the command to start your application. + Restart=always: This ensures that the service restarts if it crashes. + User=pi: Replace pi with the appropriate user if necessary. + +Save and Exit: +Press CTRL + X, then Y, and hit Enter to save the changes and exit the editor. + +Reload systemd to Recognize the New Service: +Run the following command to reload the systemd manager configuration: + +```bash +sudo systemctl daemon-reload +``` +Enable the Service to Start on Boot: +Use the following command to enable the service: + +```bash +sudo systemctl enable loudnessspy.service +``` +Start the Service Immediately (optional): +If you want to start the service right away without rebooting, run: + +```bash +sudo systemctl start loudnessspy.service +``` +Check the Status of the Service: +You can check if the service is running with: + +```bash +sudo systemctl status loudnessspy.service +``` +Reboot Your Raspberry Pi: +Restart your Raspberry Pi to ensure that the service starts automatically: + +```bash +sudo reboot +``` +After following these steps, LoudnessSpy should launch automatically when your Raspberry Pi boots up using systemd. If you encounter any issues, check the service status for error messages and ensure that the paths and permissions are correct. --- Autor: Leonhard Suckau diff --git a/rc.local b/rc.local deleted file mode 100755 index 8921b27..0000000 --- a/rc.local +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -e -# rc.local - -# Start LoudnessSpy -/opt/loudnessspy/loudnessspy & - -exit 0