Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webcamd service keeps endlessly restarting every second if there's no compatible camera attached #740

Closed
foosel opened this issue Jun 29, 2021 · 2 comments · Fixed by #741

Comments

@foosel
Copy link
Collaborator

foosel commented Jun 29, 2021

What were you doing?

  1. Booting an image on a Pi without an attached camera to test
  2. Looked into /var/log/syslog and noticed the camera daemon kept restarting every other second

What did you expect to happen?

The daemon not to restart right away, but to keep running but sleep for 120s between each scan loop.

What happened instead?

The daemon script exited. The systemd file then made it immediately restart again. Endless loop.

Did the same happen when running OctoPrint in safe mode?

Not tied to OctoPrint.

Version of OctoPi

1.0.0, current devel branch pulled this morning. Also confirmed on 0.18.0.

Printer model & used firmware incl. version

Not tied to a printer (also no printer connected)

Screenshot(s)/video(s) showing the problem:

Jun 29 12:26:15 octopiC systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Jun 29 12:26:15 octopiC root: Starting USB webcam
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: starting application
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: MJPG Streamer Version: git rev: 310b29f4a94c46652b20c4b7b6e5cf24e532af39
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: Using V4L2 device.: /dev/video10
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: Desired Resolution: 640 x 480
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: Frames Per Second.: 10
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: Format............: JPEG
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: TV-Norm...........: DEFAULT
Jun 29 12:26:15 octopiC MJPG-streamer [22341]: init_VideoIn failed
Jun 29 12:26:16 octopiC systemd[1]: webcamd.service: Succeeded.
Jun 29 12:26:16 octopiC systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Jun 29 12:26:18 octopiC systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 812.
Jun 29 12:26:18 octopiC systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Jun 29 12:26:18 octopiC systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Jun 29 12:26:18 octopiC root: Starting USB webcam
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: starting application
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: MJPG Streamer Version: git rev: 310b29f4a94c46652b20c4b7b6e5cf24e532af39
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: Using V4L2 device.: /dev/video10
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: Desired Resolution: 640 x 480
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: Frames Per Second.: 10
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: Format............: JPEG
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: TV-Norm...........: DEFAULT
Jun 29 12:26:18 octopiC MJPG-streamer [22367]: init_VideoIn failed
Jun 29 12:26:19 octopiC systemd[1]: webcamd.service: Succeeded.
Jun 29 12:26:19 octopiC systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Jun 29 12:26:20 octopiC systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 813.
Jun 29 12:26:20 octopiC systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Jun 29 12:26:20 octopiC systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Jun 29 12:26:20 octopiC root: Starting USB webcam
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: starting application
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: MJPG Streamer Version: git rev: 310b29f4a94c46652b20c4b7b6e5cf24e532af39
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: Using V4L2 device.: /dev/video10
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: Desired Resolution: 640 x 480
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: Frames Per Second.: 10
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: Format............: JPEG
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: TV-Norm...........: DEFAULT
Jun 29 12:26:20 octopiC MJPG-streamer [22393]: init_VideoIn failed
Jun 29 12:26:21 octopiC systemd[1]: webcamd.service: Succeeded.
Jun 29 12:26:21 octopiC systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Jun 29 12:26:22 octopiC systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 814.
Jun 29 12:26:22 octopiC systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Jun 29 12:26:22 octopiC systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Jun 29 12:26:22 octopiC root: Starting USB webcam
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: starting application
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: MJPG Streamer Version: git rev: 310b29f4a94c46652b20c4b7b6e5cf24e532af39
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: Using V4L2 device.: /dev/video10
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: Desired Resolution: 640 x 480
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: Frames Per Second.: 10
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: Format............: JPEG
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: TV-Norm...........: DEFAULT
Jun 29 12:26:22 octopiC MJPG-streamer [22423]: init_VideoIn failed
Jun 29 12:26:23 octopiC systemd[1]: webcamd.service: Succeeded.
Jun 29 12:26:23 octopiC systemd[1]: Started the OctoPi webcam daemon with the user specified config.

Additional notes

This seems to be caused by a combination of these lines in the webcamd script:

  if [[ ${#array_camera[@]} -eq ${#array_assigned_device[@]} ]]; then
    echo "Done bring up all configured video device"
    exit 0

and the Restart: always behaviour of the system unit file.

webcamd was originally intended to never exit (which is also while there's a while true in there) and only sleep 2min whenever inactive before running another rescan. Some changes introduced with 555b28b / #596 / #597 have changed this, and now things end in a restart storm if no webcam is connected as a consequence.

I suggest we remove the while True and instead leave it up to the restart policy in the system unit to take care of the 2min rescans. At least that's the only thing I can see working right now, since the multi cam support and array matching there changed the script so much from the original that I have no idea what I would break in touching THAT.

@foosel foosel changed the title webcamd service keeps endlessly restarting every second if there's no camera attached webcamd service keeps endlessly restarting every second if there's no compatible camera attached Jun 29, 2021
@foosel
Copy link
Collaborator Author

foosel commented Jun 29, 2021

Small addendum and correction, no working camera attached. The script will find some hardcoded video devices that apparently are memory mapped devices for encoding purposes and not compatible to mjpg streamer.

@foosel
Copy link
Collaborator Author

foosel commented Jun 29, 2021

Never mind, that's the RPi camera devices.

foosel added a commit to foosel/OctoPi that referenced this issue Jun 29, 2021
We wait for our child processes to complete, reset our "currently run
cameras" array, then wait 2min and loop.

Closes guysoft#740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant