Przeglądaj źródła

fix(x-ui.sh): read the service state without scanning the journal

check_status ran `systemctl status x-ui` and grepped its Active line. That
command also prints the unit's latest journal lines, so it reads the journal
every time the menu is drawn, before most actions, and on hosts with months
of logs the script stalled for a long time before showing its options.

`systemctl show --property=SubState` returns the same "running" state from
the unit alone. The prefix is stripped by hand rather than with --value so it
still works on systemd older than 230.

No test harness covers x-ui.sh. To demonstrate on a host with a large journal:
  time systemctl status x-ui >/dev/null
  time systemctl show --property=SubState x-ui

Refs #6629
MHSanaei 23 godzin temu
rodzic
commit
092cbd55e4
1 zmienionych plików z 2 dodań i 1 usunięć
  1. 2 1
      x-ui.sh

+ 2 - 1
x-ui.sh

@@ -897,7 +897,8 @@ check_status() {
         if [[ ! -f ${xui_service}/x-ui.service ]]; then
             return 2
         fi
-        temp=$(systemctl status x-ui | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1)
+        temp=$(systemctl show --property=SubState x-ui)
+        temp=${temp#SubState=}
         if [[ "${temp}" == "running" ]]; then
             return 0
         else