Add systemd unit file #1716
| +# -2 ensures Octoprint has a slight priority over user processes. | ||
| +Nice=-2 | ||
| + | ||
| +ExecStart=/home/pi/OctoPrint/venv/bin/octoprint serve --basedir ${BASEDIR} --config ${CONFIGFILE} --port ${PORT} --foobar $DAEMON_ARGS" |
Another thing here - I guess it's not possible to leave --config, --basedir and --port out unless the corresponding environment variables are set? The defaults in octoprint.defaults are what OctoPrint would automatically use unless overridden via command line.
|
O_o indeed. Regarding the always present If you would be willing to ignore the current
Googling systemd variable expansion suggests it might be possible to do fancy variable expansion by involving one or more instances of bash. But by now you'd be roaming into ridiculous territory.. |
What does this PR do and why is it necessary?
This PR adds a systemd unit file to allow OctoPrint to be started at boot time in a modern Linux distribution that runs the systemd init system. The unit file's defaults are suitable for the instructions provided in Setup on a Raspberry Pi running Raspbian
It tries to be backwards compatible with the existing init script with respect to envs defined in
/etc/default/octoprint, although a few of them (OCTOPRINT_USER,DAEMON,NICEandUMASK) were not possible to support in the unit file. See the unit file for instructions on howto override these.OctoPrint already comes with a SysV and Debian-style init script and configuration template. These work fine, even in a systemd world. But since most modern Linux distributions have moved over to systemd, I figured a systemd unit file would be a more proper way of doing things moving forward.
That way new OctoPrint users, some of who perhaps come in contact with Linux for the first time, don't unnecessarily get "exposed" to the old (and in the future, perhaps deprecated) way of adding boot services, but instead get to learn the modern way with
systemctl(andjournalctlfor debugging) right from the start.How was it tested? How can it be tested by the reviewer?
Any background context you want to provide?
What are the relevant tickets if any?
Screenshots (if appropriate)
Further notes
Like the author of the current init script, some helpful instructions are provided at the top of the file. They may serve as a starting point if the instructions in the wiki should be updated aswell.