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 367 forks source link

Settings in octopi.txt not being used #774

Closed stormbard closed 2 years ago

stormbard commented 2 years ago

What were you doing?

Trying to setup Raspberry Pi Camera and the settings in that file are not being used. If I wait until the system is up and then restart the webcamd service the settings in octopi.txt are used.

I netboot my RPi4. Since octopi.txt lives on the boot partition which is mounted; I can only assume, after webcamd starts the settings aren't used.

  1. Modify octopi.txt to have desired camera settings
  2. Reboot octopi
  3. Camera settings not being used.
  4. Manually restart webcamd sudo systemctl restart webcamd and setting in file are used

What did you expect to happen?

Webcam settings in octopi.txt to be used when starting up.

What happened instead?

Default settings were used instead at boot and had to manually restart webcamd to get the desired ones.

Did the same happen when running OctoPrint in safe mode?

Yes, same thing happened when I booted with OctoPrint safe mode enabled.

Version of OctoPi

OctoPrint version : 1.7.3
OctoPi version    : 0.18.0

Printer model & used firmware incl. version

N/A

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

Attached is the octopi.txt and webcamd log file. In the log file the first start of webcamd is on boot and the second is after I manually restarted it.

webcamd.log octopi.txt

I have read the FAQ.

guysoft commented 2 years ago

I suggest you post to https://community.octoprint.org/ It might depend on which camera you are using and I have no way of testing it here on my end without the hardware.

stormbard commented 2 years ago

Posted there. Forgot to mention I am using the Raspberry Pi Camera v2.

guysoft commented 2 years ago

Ok, closing since its not an OctoPi installation

stormbard commented 2 years ago

I think this is an issue in OctoPi as the webcamd service is packaged with the OS. Instead of installing it to an SD card it is netbooted. I took the octopi image file and then extracted it out onto my PXE server and configured the Pi to boot from that. If a service is going to depend on a config file it should make sure it is there before starting. Due to the parallel nature of systemd boot process that gets more complicated but it can be handled.

I added the following ExecStartPre=/usr/bin/test -f /boot/octopi.txt to /etc/systemd/system/webcamd.service under the [Service] section and that has resolved my issue. Full edited unit file below.

[Unit]
Description=the OctoPi webcam daemon with the user specified config
ConditionPathExists=/etc/octopi_streamer/mjpeg

[Service]
WorkingDirectory=/root/bin
StandardOutput=append:/var/log/webcamd.log
StandardError=append:/var/log/webcamd.log
ExecStartPre=/usr/bin/test -f /boot/octopi.txt
ExecStart=/root/bin/webcamd
Restart=always
Type=forking
RestartSec=1

[Install]
WantedBy=multi-user.target
guysoft commented 2 years ago

Ok, If you want to add better features to OctoPi that is a different matter. I hope you understand though that I can't really support OctoPi components that are ripped out of the image and placed somewhere else.

Would you like to add a PR to the line ExecStartPre=/usr/bin/test -f /boot/octopi.txt?