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

Permission denied: '/home/klippy/.config/moonraker.conf' leads to 502 Bad Gateway issue #45

Open
moookino opened this issue Nov 16, 2022 · 7 comments

Comments

@moookino
Copy link

moookino commented Nov 16, 2022

Hi,

I've tried to pull latest version and started getting 502 Bad Gateway on fluidd and mainsail, after investigation it seems they're not able to connect moonraker

From container startup log:
PermissionError: [Errno 13] Permission denied: '/home/klippy/.config/moonraker.conf' [moonraker.py:main()] - Server Shutdown return self._accessor.stat(self, follow_symlinks=follow_symlinks) File "/usr/local/lib/python3.10/pathlib.py", line 1097, in stat File "/usr/local/lib/python3.10/pathlib.py", line 1322, in is_file return S_ISREG(self.stat().st_mode) if not file_path.is_file(): File "/home/klippy/moonraker/moonraker/confighelper.py", line 1012, in _parse_file self._parse_file(main_conf, []) File "/home/klippy/moonraker/moonraker/confighelper.py", line 1028, in read_file source.read_file(start_path) File "/home/klippy/moonraker/moonraker/confighelper.py", line 1040, in get_configuration config = confighelper.get_configuration(self, self.app_args) File "/home/klippy/moonraker/moonraker/moonraker.py", line 129, in _parse_config self.config = config = self._parse_config() File "/home/klippy/moonraker/moonraker/moonraker.py", line 67, in __init__ server = Server(app_args, file_logger, event_loop) File "/home/klippy/moonraker/moonraker/moonraker.py", line 460, in main Traceback (most recent call last): During handling of the above exception, another exception occurred: stat = file_path.stat() File "/home/klippy/moonraker/moonraker/confighelper.py", line 924, in _parse_file [moonraker.py:main()] - Moonraker Error [utils.py:setup_logging()] - python_version: 3.10.7 (main, Sep 13 2022, 03:02:33) [GCC 10.2.1 20210110] [utils.py:setup_logging()] - software_version: v0.7.1-660-g5d856b9 [utils.py:setup_logging()] - log_file: /var/log/klipper/moonraker.log [utils.py:setup_logging()] - startup_warnings: []
Have something changed in the last docker images updates?

@speendo
Copy link

speendo commented Nov 18, 2022

I run mainsail but I seem to be affected by the same issue.
It seems like something in Moonraker has changed and now it's not working anymore...

@moookino
Copy link
Author

I've ended up using some older version from docker build as a workaround, but having issues with config as well, so put all needed items in the printer.cfg

@moookino
Copy link
Author

@speendo I ended up migrating to https://github.com/mkuf/prind, seems like more robust and better maintained solution with same set of feature/frontends

@speendo
Copy link

speendo commented Nov 24, 2022

Thanks. I was using prind before, it sort of worked but this project was easier to handle for me.
Well, at least until recently :)

@dimalo do you have any plans about this issue? (just to make it clear: I am fine if you don't have any, just want to know)

@speendo
Copy link

speendo commented Dec 3, 2022

I think I might have understood where the problem is coming from.

Recent versions of moonraker expect all files to be in the directory /home/<user>/printer_data/, e.g. /home/<user>/config or /home/<user>/gcodes.

This docker image however is configured to store all files at /home/klippy (where klippy is the user name defined in the Dockerfile). So the config lays in /home/klippy/.config and gcodes files are at /home/klippy/gcode_files.

For an ideal solution, it would be best to follow the standard, that moonraker expects. However, to do this, one would not only need to change the Dockerfile (which would be okay), but also many people who linked their gcode or settings folder in the docker-compose.yml would need to change their settings.

For the moment, I decided for a quick workaround (that I actually would need to repeat every time I update my docker image, so take care). It works like this

  1. Go to klipper/moonraker.ini and change the line command=/home/klippy/moonraker-env/bin/python /home/klippy/moonraker/moonraker/moonraker.py -l /var/log/klipper/moonraker.log -c /home/klippy/.config/moonraker.conf to command=/home/klippy/moonraker-env/bin/python /home/klippy/moonraker/moonraker/moonraker.py -l /var/log/klipper/moonraker.log -d /home/klippy -c /home/klippy/.config/moonraker.conf
  2. Go into the running docker container with docker exec -it klipper /bin/bash
  3. In the docker container delete the directories /home/klippy/printer_data/config and /home/klippy/printer_data/gcodes. Make sure that you backup the content of those folders, in case they are not empty. You have been warned! To delete a folder, use `rm -r <folder_path>
  4. Create symlinks to replace the folders you just deleted: Run ln -s /home/klippy/.config /home/klippy/printer_data/config and ln -s /home/klippy/gcode_files /home/klippy/printer_data/gcodes.
  5. Restart the docker container.
  6. In case you still have problems, they might be caused by permission problems. Make sure that the user klippy has read and write access to the folders you just linked (you can check by logging into the docker container again and run ls -al /home/klippy).

It would be possible to integrate this workaround in the dockerfile, however it might be better to think of a solution that is consistent with the moonraker default configuration.

@speendo
Copy link

speendo commented Dec 9, 2022

The problems should be solved with my pull request or by using https://github.com/speendo/klipper-web-control-docker/tree/main in the mean time

@sammcj
Copy link

sammcj commented Jan 11, 2023

@dimalo any update on getting this fix merged in?

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

No branches or pull requests

3 participants