fix(deploy): 用 exec 列表形式重写 redis command

参数逐项传递,不再经 sh 拼接,避免密码含 shell 特殊字符时被展开或截断;
空密码时按 redis 语义不设密码。
This commit is contained in:
ling
2026-09-26 17:56:19 +08:00
parent a3eb7ef302
commit c802c45e37
3 changed files with 33 additions and 33 deletions
+11 -11
View File
@@ -287,17 +287,17 @@ services:
hard: 100000
volumes:
- redis_data:/data
# The command is one quoted script for the inner `sh -c`. Compose keeps
# the newlines inside the quoted string, so every line needs a trailing
# `\` — without it, `redis-server` on the first line runs with no flags
# at all, and the --save/--appendonly/--appendfsync lines are never read.
command: >
sh -c '
redis-server \
--save 60 1 \
--appendonly yes \
--appendfsync everysec \
${REDIS_PASSWORD:+--requirepass "$REDIS_PASSWORD"}'
command:
- redis-server
- --save
- "60"
- "1"
- --appendonly
- "yes"
- --appendfsync
- everysec
- --requirepass
- ${REDIS_PASSWORD:-}
environment:
- TZ=${TZ:-Asia/Shanghai}
# REDISCLI_AUTH is used by redis-cli for authentication (safer than -a flag)