Skip to content

Commit

Permalink
chg: Clean fail if valkey < 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Nov 4, 2024
1 parent 59903c0 commit bab7d9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
10 changes: 9 additions & 1 deletion bin/run_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 38 in bin/run_backend.py

View workflow job for this annotation

GitHub Actions / build (3.10)

potentailly ==> potentially

Check failure on line 38 in bin/run_backend.py

View workflow job for this annotation

GitHub Actions / build (3.11)

potentailly ==> potentially

Check failure on line 38 in bin/run_backend.py

View workflow job for this annotation

GitHub Actions / build (3.12)

potentailly ==> potentially

Check failure on line 38 in bin/run_backend.py

View workflow job for this annotation

GitHub Actions / build (3.13)

potentailly ==> potentially
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:
Expand Down
6 changes: 5 additions & 1 deletion bin/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
19 changes: 17 additions & 2 deletions cache/run_redis.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bab7d9c

Please sign in to comment.