I installed the systemd service exactly as provided by commit 310b29f4a94c46652b20c4b7b6e5cf24e532af39
By default, the systemd service only waits for After=network.target
I had the service run for /dev/video0 and ensured all permissions were correct
Race Condition: The USB device for /dev/video0 was not yet available by the time mjpg_streamer@.service started
On our system, I created a custom script that would poll for /dev/video0 and poll v4l2-ctl --list-devices for our specific camera by USB name, e.g. a string such as CAM2 PRO
Then it would run the mjpg_streamer program with expected parameters
I modified the mjpg_streamer@.service to use that script instead
Then it has been stable
Possible explanations:
The USB devices are not ready by the time network.target is done
Our custom service turns on the USB board
Possible fixes:
Poll for the @ parameter before starting the mjpg_streamer@.service
Create a script that gets installed with the deb package, and the service will run /usr/local/bin/mjpg_streamer_startup.sh %I
Could optionally check for permissions and see if access is allowed, making an easy to read message for troubleshooting
After=network.target
/dev/video0
and ensured all permissions were correct/dev/video0
was not yet available by the time mjpg_streamer@.service started/dev/video0
and pollv4l2-ctl --list-devices
for our specific camera by USB name, e.g. a string such asCAM2 PRO
Possible explanations:
Possible fixes:
@
parameter before starting the mjpg_streamer@.service/usr/local/bin/mjpg_streamer_startup.sh %I