OctoPrint systemd service file for autostarting OctoPrint
After you have installed OctoPrint using
sudo pip3 install OctoPrint
you can create /etc/systemd/system/octoprint.service
with the following content (depending on your setup, you might need to replace the user & group pi
by the name of the user that should run OctoPrint):
[Unit]
Description=octoprint
[Service]
ExecStart=/usr/local/bin/octoprint serve
WorkingDirectory=/data
Restart=always
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
After creating the file, enable autostart & start the service using
sudo systemctl enable --now octoprint