diff --git a/bin/run_backend.py b/bin/run_backend.py index 7d363090..9550a91b 100755 --- a/bin/run_backend.py +++ b/bin/run_backend.py @@ -33,7 +33,15 @@ def launch_cache(storage_directory: Path | None=None) -> None: if not storage_directory: storage_directory = get_homedir() if not check_running('cache'): - Popen(["./run_redis.sh"], cwd=storage_directory / 'cache') + process = Popen(["./run_redis.sh"], cwd=(storage_directory / 'cache')) + try: + # Give time for the process to start (and potentailly fail) + process.wait(timeout=5) + except TimeoutError: + pass + process.poll() + if process.returncode == 1: + raise Exception('Failed to start Redis cache database.') def shutdown_cache() -> None: diff --git a/bin/start.py b/bin/start.py index d0ed4307..468d458a 100755 --- a/bin/start.py +++ b/bin/start.py @@ -10,7 +10,11 @@ def main() -> None: get_homedir() print('Start backend (redis)...') p = run(['run_backend', '--start']) - p.check_returncode() + try: + p.check_returncode() + except Exception: + print('Failed to start the backend, exiting.') + return print('done.') print('Start unoserver...') Popen(['unoserver_launcher']) diff --git a/cache/run_redis.sh b/cache/run_redis.sh index c7e47b52..f9acbc52 100755 --- a/cache/run_redis.sh +++ b/cache/run_redis.sh @@ -1,10 +1,25 @@ #!/bin/bash set -e -set -x +# set -x if [ -f ../../valkey/src/valkey-server ]; then + if [[ ` ../../valkey/src/valkey-server -v` == *"v=7."* ]] ; then + echo "You're using valkey 7, please upgrade do valkey 8" + exit 1 + fi ../../valkey/src/valkey-server ./cache.conf -else +elif [ -f ../../redis/src/redis-server ]; then + if [[ ` ../../redis/src/redis-server -v` == *"v=7."* ]] ; then + echo "You're using redis 7, please upgrade do valkey 8"; + exit 1 + fi ../../redis/src/redis-server ./cache.conf +else + if [[ `/usr/bin/redis-server -v` == *"v=7."* ]] ; then + echo "You're using redis 7, please upgrade do valkey 8"; + exit 1 + fi + echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2 + /usr/bin/redis-server ./cache.conf fi