Skip to content

Commit cebed89

Browse files
committed
Allow REDIS_CLUSTER environment variable to use Redis in cluster mode
1 parent 85eb58a commit cebed89

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ To use Redis for memory caching as well as PHP session storage, specify the foll
238238
- `REDIS_HOST_PORT` (default: `6379`) Optional port for Redis, only use for external Redis servers that run on non-standard ports.
239239
- `REDIS_HOST_PASSWORD` (not set by default) Redis password
240240

241+
To use Redis in cluster mode, you can use
242+
243+
- `REDIS_CLUSTER` (not set by default) Name and port number of a redis host.
244+
241245
Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html) for more information.
242246

243247
### E-mail (SMTP) Configuration

docker-entrypoint.sh

+20
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,26 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
132132
} > /usr/local/etc/php/conf.d/redis-session.ini
133133
fi
134134

135+
if [ -n "${REDIS_CLUSTER+x}" ]; then
136+
137+
echo "Configuring Rediscluster as session handler"
138+
{
139+
file_env REDIS_HOST_PASSWORD
140+
echo 'session.save_handler = rediscluster'
141+
# check if redis password has been set
142+
if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
143+
echo "session.save_path = \"seed[]=${REDIS_CLUSTER}&auth=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"seed[]=${REDIS_CLUSTER}\""
146+
fi
147+
echo "redis.session.locking_enabled = 1"
148+
echo "redis.session.lock_retries = -1"
149+
# redis.session.lock_wait_time is specified in microseconds.
150+
# Wait 10ms before retrying the lock rather than the default 2ms.
151+
echo "redis.session.lock_wait_time = 10000"
152+
} > /usr/local/etc/php/conf.d/redis-session.ini
153+
fi
154+
135155
# If another process is syncing the html folder, wait for
136156
# it to be done, then escape initalization.
137157
(

0 commit comments

Comments
 (0)