forked from platypush/platypush
[#401] Added --redis-bin
/PLATYPUSH_REDIS_BIN
option/variable.
Closes: #401
This commit is contained in:
parent
6d425b06f7
commit
38cf102397
3 changed files with 44 additions and 5 deletions
|
@ -1178,6 +1178,15 @@ redis:
|
||||||
password: redis-pass
|
password: redis-pass
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If `--start-redis` is set, the application can be configured to start a custom
|
||||||
|
`redis-server` executable through the:
|
||||||
|
|
||||||
|
1. `--redis-bin` command-line option.
|
||||||
|
2. `PLATYPUSH_REDIS_BIN` environment variable.
|
||||||
|
|
||||||
|
Alternative drop-in implementations such as `keydb-server`, `valkey` or
|
||||||
|
`redict` are also supported.
|
||||||
|
|
||||||
### nginx
|
### nginx
|
||||||
|
|
||||||
If you want to access your Platypush web panel outside your home network, it may
|
If you want to access your Platypush web panel outside your home network, it may
|
||||||
|
|
|
@ -32,6 +32,9 @@ class Application:
|
||||||
# Default Redis port
|
# Default Redis port
|
||||||
_default_redis_port = 6379
|
_default_redis_port = 6379
|
||||||
|
|
||||||
|
# Default Redis binary, if --start-redis is set
|
||||||
|
_default_redis_bin = 'redis-server'
|
||||||
|
|
||||||
# backend_name => backend_obj map
|
# backend_name => backend_obj map
|
||||||
backends = None
|
backends = None
|
||||||
|
|
||||||
|
@ -55,6 +58,7 @@ class Application:
|
||||||
start_redis: bool = False,
|
start_redis: bool = False,
|
||||||
redis_host: Optional[str] = None,
|
redis_host: Optional[str] = None,
|
||||||
redis_port: Optional[int] = None,
|
redis_port: Optional[int] = None,
|
||||||
|
redis_bin: Optional[str] = None,
|
||||||
ctrl_sock: Optional[str] = None,
|
ctrl_sock: Optional[str] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -142,10 +146,11 @@ class Application:
|
||||||
:param verbose: Enable debug/verbose logging, overriding the stored
|
:param verbose: Enable debug/verbose logging, overriding the stored
|
||||||
configuration (default: False).
|
configuration (default: False).
|
||||||
:param start_redis: If set, it starts a managed Redis instance upon
|
:param start_redis: If set, it starts a managed Redis instance upon
|
||||||
boot (it requires the ``redis-server`` executable installed on the
|
boot (it requires Redis installed on the server, see
|
||||||
server). This is particularly useful when running the application
|
``redis_bin``). This is particularly useful when running the
|
||||||
inside of Docker containers, without relying on ``docker-compose``
|
application inside of Docker containers, without relying on
|
||||||
to start multiple containers, and in tests (default: False).
|
``docker-compose`` to start multiple containers, and in tests
|
||||||
|
(default: False).
|
||||||
:param redis_host: Host of the Redis server to be used. The order of
|
:param redis_host: Host of the Redis server to be used. The order of
|
||||||
precedence is:
|
precedence is:
|
||||||
|
|
||||||
|
@ -168,6 +173,16 @@ class Application:
|
||||||
the configuration file.
|
the configuration file.
|
||||||
- ``6379``
|
- ``6379``
|
||||||
|
|
||||||
|
:param redis_bin: Path to the Redis server executable, if ``start_redis``
|
||||||
|
is set. Alternative drop-in Redis implementations such as
|
||||||
|
``keydb-server``, ``valkey``, ``redict`` can be used. The order of
|
||||||
|
precedence is:
|
||||||
|
|
||||||
|
- The ``redis_bin`` parameter (or the ``--redis-bin`` command
|
||||||
|
line argument).
|
||||||
|
- The ``PLATYPUSH_REDIS_BIN`` environment variable.
|
||||||
|
- ``redis-server``
|
||||||
|
|
||||||
:param ctrl_sock: If set, it identifies a path to a UNIX domain socket
|
:param ctrl_sock: If set, it identifies a path to a UNIX domain socket
|
||||||
that the application can use to send control messages (e.g. STOP
|
that the application can use to send control messages (e.g. STOP
|
||||||
and RESTART) to its parent.
|
and RESTART) to its parent.
|
||||||
|
@ -211,6 +226,11 @@ class Application:
|
||||||
self.start_redis = start_redis
|
self.start_redis = start_redis
|
||||||
self.redis_host = redis_host or os.environ.get('PLATYPUSH_REDIS_HOST')
|
self.redis_host = redis_host or os.environ.get('PLATYPUSH_REDIS_HOST')
|
||||||
self.redis_port = redis_port or os.environ.get('PLATYPUSH_REDIS_PORT')
|
self.redis_port = redis_port or os.environ.get('PLATYPUSH_REDIS_PORT')
|
||||||
|
self.redis_bin = (
|
||||||
|
redis_bin
|
||||||
|
or os.environ.get('PLATYPUSH_REDIS_BIN')
|
||||||
|
or self._default_redis_bin
|
||||||
|
)
|
||||||
self._redis_conf = {
|
self._redis_conf = {
|
||||||
'host': self.redis_host or 'localhost',
|
'host': self.redis_host or 'localhost',
|
||||||
'port': self.redis_port or self._default_redis_port,
|
'port': self.redis_port or self._default_redis_port,
|
||||||
|
@ -262,7 +282,7 @@ class Application:
|
||||||
port = self._redis_conf['port']
|
port = self._redis_conf['port']
|
||||||
log.info('Starting local Redis instance on %s', port)
|
log.info('Starting local Redis instance on %s', port)
|
||||||
redis_cmd_args = [
|
redis_cmd_args = [
|
||||||
'redis-server',
|
self.redis_bin,
|
||||||
'--bind',
|
'--bind',
|
||||||
'localhost',
|
'localhost',
|
||||||
'--port',
|
'--port',
|
||||||
|
|
|
@ -159,6 +159,16 @@ def parse_cmdline(args: Sequence[str]) -> argparse.Namespace:
|
||||||
"configuration file",
|
"configuration file",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--redis-bin',
|
||||||
|
dest='redis_bin',
|
||||||
|
required=False,
|
||||||
|
default=None,
|
||||||
|
help="Path to the redis-server executable, if --start-redis is "
|
||||||
|
"specified. Drop-in replacements such as keydb-server, valkey or redict "
|
||||||
|
"are also supported",
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--ctrl-sock',
|
'--ctrl-sock',
|
||||||
dest='ctrl_sock',
|
dest='ctrl_sock',
|
||||||
|
|
Loading…
Reference in a new issue