Arksine / moonraker

Web API Server for Klipper
https://moonraker.readthedocs.io
GNU General Public License v3.0
1.05k stars 406 forks source link

Cannot shutdown or reboot host #788

Closed xiaojie0815 closed 4 months ago

xiaojie0815 commented 8 months ago

What happened

What happened? When trying to shutdown or reboot the host system for the GUI, it shows the following error in the log and just ignores the command: 2024-01-11 21:24:10,561 [common.py:build_error()] - JSON-RPC Request Error - Requested Method: machine.reboot, Code: -31000, Message: Interactive authentication required.

KlipperScreen.log As shown below QQ截图20240111223118

I tried the following commands but none of them work the first method: cd ~/moonraker/scripts ./set-policykit-rules.sh sudo service moonraker restart The second method: cd ~/moonraker/scripts ./install-moonraker.sh

Client

Fluidd, KlipperScreen

Browser

Chrome

How to reproduce

Go to system -> shutdown -> host system

No error, and host shutdown.

Additional information

No response

xiaojie0815 commented 8 months ago

system message 11

Arksine commented 8 months ago

It looks like you are trying to run Moonraker on a smartphone. While this may work for general purpose usage, the distribution could be missing packages Moonraker depends on such as dbus and policykit for its extended functionality. Alternatively it may not use systemd as the init manager, in which case Moonraker will be unable to perform actions such as shutdown and reboot. If its running systemd but missing the aforementioned packages you could try to configure the provider option in [machine] to systemd_cli.

You could attach moonraker.log for me to get a more detailed look at the system and I'll see if I can provide further guidance, but I suspect the answer is that Moonraker will be unable to perform a shutdown in your environment.

xiaojie0815 commented 8 months ago

It looks like you are trying to run Moonraker on a smartphone. While this may work for general purpose usage, the distribution could be missing packages Moonraker depends on such as dbus and policykit for its extended functionality. Alternatively it may not use systemd as the init manager, in which case Moonraker will be unable to perform actions such as shutdown and reboot. If its running systemd but missing the aforementioned packages you could try to configure the provider option in [machine] to systemd_cli.

You could attach moonraker.log for me to get a more detailed look at the system and I'll see if I can provide further guidance, but I suspect the answer is that Moonraker will be unable to perform a shutdown in your environment.

moonraker.log This is the log file I generated. Please take a look. Thank you very much for your help. @Arksine

xiaojie0815 commented 8 months ago

@Arksine

I compared the software packages that can be installed on the Debian system.

I uninstalled the following packages 1.dbus-bin 2.dbus-daemon

  1. dbus-session-bus-common
  2. dbus-system-bus-common

Then install these two packages

  1. sudo apt install x11-utils
  2. sudo apt install xdg-utils

After uninstalling and reinstalling Moonraker, the shutdown and restart commands now work normally. I don't know the specific reason yet.

Arksine commented 4 months ago

As this discussion seems to have concluded I'm going to close this. It appears the cause is distro related.