Skip to content

Instantly share code, notes, and snippets.

@jchodakowski
Created December 31, 2023 10:12
Show Gist options
  • Save jchodakowski/463d145cc151cb72e20f80aa395bc529 to your computer and use it in GitHub Desktop.
Save jchodakowski/463d145cc151cb72e20f80aa395bc529 to your computer and use it in GitHub Desktop.
Simple systemd service descriptor for running on raspberry-pi with added self-restart. Pi's don't seem to like long running cameras and the reasons vary. The easiest work around is to just refresh the process on a regular basis.
[Unit]
Description=Streams video with Raspberry Pi Camera
After=syslog.target
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/mjpg_streamer -b \
-i '/usr/local/lib/mjpg-streamer/input_uvc.so -n -f 10 -r 1280x720' \
-o '/usr/local/lib/mjpg-streamer/output_http.so -p 8085 -w /usr/local/share/mjpg-streamer/www'
Restart=always
RestartSec=5
RuntimeMaxSec=12h
Environment=
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment