fix: redis_disable/enable - auto-detect service name (redis6, redis7, etc.)

main
Anthony 2026-02-28 15:34:54 +08:00
parent 8356c11139
commit 3d8ea81386
1 changed files with 2 additions and 2 deletions

View File

@ -856,7 +856,7 @@ actions:
- cmd[cp]: - cmd[cp]:
user: root user: root
commands: commands:
- systemctl stop redis - REDIS_SVC=$(systemctl list-units --type=service --all | grep -oP '[\w@-]*redis[\w@-]*\.service' | head -1 | sed 's/\.service//') && [ -n "$REDIS_SVC" ] && systemctl stop "$REDIS_SVC" || echo "No Redis service found"
- return: - return:
type: info type: info
message: "Redis has been stopped successfully" message: "Redis has been stopped successfully"
@ -864,7 +864,7 @@ actions:
- cmd[cp]: - cmd[cp]:
user: root user: root
commands: commands:
- systemctl restart redis - REDIS_SVC=$(systemctl list-units --type=service --all | grep -oP '[\w@-]*redis[\w@-]*\.service' | head -1 | sed 's/\.service//') && [ -n "$REDIS_SVC" ] && systemctl restart "$REDIS_SVC" || echo "No Redis service found"
- return: - return:
type: info type: info
message: "Redis has been successfully restarted" message: "Redis has been successfully restarted"