Create an autostart script - Teraskull/music_led_strip_control-wiki GitHub Wiki

Add MLSC to the autostart.

Using a systemd service, each time Raspberry Pi reboots, MLSC will run.

Stop MLSC if it is still running.

  1. Create a file mlsc.service in /etc/systemd/system/:
sudo touch /etc/systemd/system/mlsc.service
  1. Add the following to the created mlsc.service file:
[Unit]
Description=Music LED Strip Control
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/share/music_led_strip_control/server
ExecStart=python3 main.py
Restart=always
RestartSec=5
KillMode=control-group

[Install]
WantedBy=multi-user.target
  1. Run the following commands to enable and start MLSC:
sudo systemctl daemon-reload

sudo systemctl enable mlsc.service

sudo systemctl start mlsc.service
  1. Reboot:
sudo reboot
  1. Check if the service is running:
sudo systemctl status mlsc.service

MLSC should now restart on reboot.

To remove the service from autostart, run the following commands:

sudo systemctl stop mlsc.service

sudo systemctl disable mlsc.service

Note: The WorkingDirectory specified in the service is /share. If you did not change anything during the installation, the service should work without issues.

Revision 2.2