Skip to content

Commit 29b115a

Browse files
committed
redis.config.php: allow to configure redis.cluster
Signed-off-by: Simon L. <szaimen@e.mail.de>
1 parent 759cab0 commit 29b115a

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

Containers/nextcloud/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ RUN set -ex; \
138138
} > /usr/local/etc/php/conf.d/nextcloud.ini; \
139139
\
140140
{ \
141-
echo 'session.save_handler = redis'; \
142-
echo 'session.save_path = "tcp://${REDIS_HOST}:${REDIS_PORT}?database=${REDIS_DB_INDEX}${REDIS_USER_AUTH}&auth[]=${REDIS_HOST_PASSWORD}"'; \
141+
echo 'session.save_handler = rediscluster'; \
142+
echo 'session.save_path = "seed[]=${REDIS_HOST}:${REDIS_PORT}&seed[]=${REDIS_HOST_2}:${REDIS_PORT_2}&seed[]=${REDIS_HOST_3}:${REDIS_PORT_3}&seed[]=${REDIS_HOST_4}:${REDIS_PORT_4}&seed[]=${REDIS_HOST_5}:${REDIS_PORT_5}&seed[]=${REDIS_HOST_6}:${REDIS_PORT_6}&seed[]=${REDIS_HOST_7}:${REDIS_PORT_7}&seed[]=${REDIS_HOST_8}:${REDIS_PORT_8}&seed[]=${REDIS_HOST_9}:${REDIS_PORT_9}&timeout=0&read_timeout=0&failover=error&persistent=1&auth=${REDIS_HOST_PASSWORD}&stream[verify_peer]=0"'; \
143143
echo 'redis.session.locking_enabled = 1'; \
144144
echo 'redis.session.lock_retries = -1'; \
145145
echo 'redis.session.lock_wait_time = 10000'; \

Containers/nextcloud/config/redis.config.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
if (getenv('REDIS_HOST')) {
2+
if (!getenv('REDIS_HOST_2')) {
33
$CONFIG = array(
44
'memcache.distributed' => '\OC\Memcache\Redis',
55
'memcache.locking' => '\OC\Memcache\Redis',
@@ -17,7 +17,33 @@
1717
$CONFIG['redis']['dbindex'] = (int) getenv('REDIS_DB_INDEX');
1818
}
1919

20-
if (getenv('REDIS_USER_AUTH') !== false) {
20+
if (getenv('REDIS_USER_AUTH')) {
2121
$CONFIG['redis']['user'] = str_replace("&auth[]=", "", getenv('REDIS_USER_AUTH'));
2222
}
23+
} else {
24+
$CONFIG = array(
25+
'memcache.distributed' => '\OC\Memcache\Redis',
26+
'memcache.locking' => '\OC\Memcache\Redis',
27+
'redis.cluster' => array(
28+
'password' => (string) getenv('REDIS_HOST_PASSWORD'),
29+
'timeout' => 0.0,
30+
'read_timeout' => 0.0,
31+
'failover_mode' => \RedisCluster::FAILOVER_ERROR,
32+
'seeds' => array(
33+
getenv('REDIS_HOST') . ':' . (string)getenv('REDIS_PORT'),
34+
getenv('REDIS_HOST_2') . ':' . (string)getenv('REDIS_PORT_2'),
35+
getenv('REDIS_HOST_3') . ':' . (string)getenv('REDIS_PORT_3'),
36+
getenv('REDIS_HOST_4') . ':' . (string)getenv('REDIS_PORT_4'),
37+
getenv('REDIS_HOST_5') . ':' . (string)getenv('REDIS_PORT_5'),
38+
getenv('REDIS_HOST_6') . ':' . (string)getenv('REDIS_PORT_6'),
39+
getenv('REDIS_HOST_7') . ':' . (string)getenv('REDIS_PORT_7'),
40+
getenv('REDIS_HOST_8') . ':' . (string)getenv('REDIS_PORT_8'),
41+
getenv('REDIS_HOST_9') . ':' . (string)getenv('REDIS_PORT_9'),
42+
),
43+
),
44+
);
45+
46+
if (getenv('REDIS_USER_AUTH')) {
47+
$CONFIG['redis.cluster']['user'] = str_replace("&auth[]=", "", getenv('REDIS_USER_AUTH'));
48+
}
2349
}

0 commit comments

Comments
 (0)