mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-30 19:22:10 +03:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user