guysoft / OctoPi

Scripts to build OctoPi, a Raspberry PI distro for controlling 3D printers over the web
GNU General Public License v3.0
2.45k stars 368 forks source link

Changed HLS root directory from `/tmp` to `/run`. #706

Closed chudsaviet closed 3 years ago

chudsaviet commented 3 years ago

I had to move the stream to /run because of next reasons:

  1. Suprisingly, /tmp in RaspberryPi OS is not mounted as tmpfs, but instead is kept on the SD card. So HLS stream causes excessive wear on the card.
  2. Under Filesystem Hierarchy Standard, /run is 'Run-time variable data: Information about the running system since last boot, e.g., currently logged-in users and running daemons. Files under this directory must be either removed or truncated at the beginning of the boot process, but this is not necessary on systems that provide this directory as a temporary filesystem (tmpfs). '
guysoft commented 3 years ago

I assume you had to change from webcam to root for writing permissions?

chudsaviet commented 3 years ago

Yup. There is no other way to make a directory in ‘run’ with ‘ExecPre’ statement. So I had to change user to ‘root’ and run ffmpeg using ‘sudo -u webcam’.

guysoft commented 3 years ago

You might be able to do something like this: User=webcam Source I wrote with example: https://github.com/guysoft/AlarmBot/blob/master/src/config/alarmbot.service#L11

chudsaviet commented 3 years ago

Unfortunately not, because /run is owned by root and don't have write permissions to 'others'. ExecStartPre is running under the user specified in User statement.