mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-19 04:47:52 +00:00
Merge pull request #350 from cytopia/redis-password
Redis startup options
This commit is contained in:
commit
58da41ab85
@ -127,8 +127,28 @@ function loadClass($class) {
|
||||
break;
|
||||
|
||||
case 'Redis':
|
||||
|
||||
// Check if redis is using a password
|
||||
$REDIS_ROOT_PASSWORD = '';
|
||||
|
||||
$_REDIS_ARGS = loadClass('Helper')->getEnv('REDIS_ARGS');
|
||||
$_REDIS_PASS = preg_split("/--requirepass\s+/", $_REDIS_ARGS);
|
||||
if (is_array($_REDIS_PASS) && count($_REDIS_PASS)) {
|
||||
// In case the option is specified multiple times, use the last effective one.
|
||||
$_REDIS_PASS = $_REDIS_PASS[count($_REDIS_PASS)-1];
|
||||
if (strlen($_REDIS_PASS) > 0) {
|
||||
$REDIS_ROOT_PASSWORD = $_REDIS_PASS;
|
||||
}
|
||||
}
|
||||
|
||||
loadFile($class, $cnt_dir);
|
||||
$_LOADED_LIBS[$class] = \devilbox\Redis::getInstance($GLOBALS['REDIS_HOST_NAME']);
|
||||
if ($REDIS_ROOT_PASSWORD == '') {
|
||||
$_LOADED_LIBS[$class] = \devilbox\Redis::getInstance($GLOBALS['REDIS_HOST_NAME']);
|
||||
} else {
|
||||
$_LOADED_LIBS[$class] = \devilbox\Redis::getInstance($GLOBALS['REDIS_HOST_NAME'], array(
|
||||
'pass' => $REDIS_ROOT_PASSWORD,
|
||||
));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Memcd':
|
||||
@ -143,7 +163,7 @@ function loadClass($class) {
|
||||
|
||||
// Get optional docker classes
|
||||
default:
|
||||
// Redis
|
||||
// Unknown class
|
||||
exit('Class does not exist: '.$class);
|
||||
}
|
||||
return $_LOADED_LIBS[$class];
|
||||
|
@ -44,6 +44,9 @@ class Redis extends BaseClass implements BaseInterface
|
||||
$this->setConnectErrno(1);
|
||||
//loadClass('Logger')->error($this->_connect_error);
|
||||
} else {
|
||||
if (array_key_exists('pass', $data)) {
|
||||
$redis->auth($data['pass']);
|
||||
}
|
||||
$redis->set('devilbox-version', $GLOBALS['DEVILBOX_VERSION'].' ('.$GLOBALS['DEVILBOX_DATE'].')');
|
||||
$this->_redis = $redis;
|
||||
}
|
||||
|
@ -403,6 +403,11 @@ services:
|
||||
redis:
|
||||
image: redis:${REDIS_SERVER:-3.2}
|
||||
|
||||
# Apply custom arguments to redis startup
|
||||
command: redis-server ${REDIS_ARGS:- }
|
||||
environment:
|
||||
- REDIS_ARGS=${REDIS_ARGS:- }
|
||||
|
||||
ports:
|
||||
# [local-machine:]local-port:docker-port
|
||||
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_REDIS}:6379"
|
||||
|
@ -96,7 +96,8 @@ rst_epilog = """
|
||||
linkcheck_ignore = [
|
||||
r'http(s)?://localhost(/)?.*',
|
||||
r'http(s)?://127\.0\.0\.1(/)?.*',
|
||||
r'http(s)?://.+\.loc$'
|
||||
r'http(s)?://.+\.loc$',
|
||||
r'http(s)?://.+\.loc/.+$'
|
||||
]
|
||||
linkcheck_retries = 5
|
||||
linkcheck_timeout = 60
|
||||
|
@ -1542,6 +1542,47 @@ connect to PostgreSQL and will not be able to display information inside the bun
|
||||
Keep this variable in sync with the actual PostgreSQL password.
|
||||
|
||||
|
||||
.. _env_redis:
|
||||
|
||||
Redis
|
||||
-----
|
||||
|
||||
REDIS_ARGS
|
||||
^^^^^^^^^^
|
||||
|
||||
This option lets you add extra startup parameters to Redis. This could include adding a password
|
||||
protection to Redis or increasing its verbosity.
|
||||
|
||||
+-------------------------+------------------------------------------+----------------+
|
||||
| Name | Allowed values | Default value |
|
||||
+=========================+==========================================+================+
|
||||
| ``REDIS_ARGS`` | valid ``redis-server`` startup parameter | empty |
|
||||
+-------------------------+------------------------------------------+----------------+
|
||||
|
||||
Example: Adding password protection
|
||||
"""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
REDIS_ARGS=--requirepass my-redis-root-password
|
||||
|
||||
.. important:: Do not quote the password and do not use spaces inside the password.
|
||||
|
||||
Example: Increasing verbosity
|
||||
"""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
REDIS_ARGS=--loglevel verbose
|
||||
|
||||
Example: Combining options
|
||||
""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
REDIS_ARGS=--loglevel verbose --requirepass my-redis-root-password
|
||||
|
||||
|
||||
Bind
|
||||
----
|
||||
|
||||
|
20
env-example
20
env-example
@ -577,6 +577,26 @@ HOST_PORT_PGSQL=5432
|
||||
HOST_PORT_REDIS=6379
|
||||
|
||||
|
||||
###
|
||||
### Custom startup arguments
|
||||
###
|
||||
### Apply custom startup arguments to redis
|
||||
###
|
||||
### Example: Password protection
|
||||
### Add password protection to the Redis server by specifying it should
|
||||
### require a password.
|
||||
### Note: Do not add quotes or spaces to the password
|
||||
###
|
||||
### REDIS_ARGS=--requirepass my-redis-root-password
|
||||
###
|
||||
### Example: Verbosity
|
||||
###
|
||||
### REDIS_ARGS=--loglevel verbose
|
||||
###
|
||||
REDIS_ARGS=
|
||||
#REDIS_ARGS=--loglevel verbose --requirepass my-redis-root-password
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
###
|
||||
|
Loading…
Reference in New Issue
Block a user