mirror of https://github.com/CIRCL/lookyloo
fix: Check valkey version, stop if < 8
Fix https://github.com/Lookyloo/lookyloo/issues/970pull/986/head
parent
6c3fa8074f
commit
c41d720a2e
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
@ -29,7 +30,15 @@ def launch_cache(storage_directory: Path | None=None) -> None:
|
||||||
if not storage_directory:
|
if not storage_directory:
|
||||||
storage_directory = get_homedir()
|
storage_directory = get_homedir()
|
||||||
if not check_running('cache'):
|
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(storage_directory: Path | None=None) -> None:
|
def shutdown_cache(storage_directory: Path | None=None) -> None:
|
||||||
|
@ -44,7 +53,15 @@ def launch_indexing(storage_directory: Path | None=None) -> None:
|
||||||
if not storage_directory:
|
if not storage_directory:
|
||||||
storage_directory = get_homedir()
|
storage_directory = get_homedir()
|
||||||
if not check_running('indexing'):
|
if not check_running('indexing'):
|
||||||
Popen(["./run_redis.sh"], cwd=(storage_directory / 'indexing'))
|
process = Popen(["./run_redis.sh"], cwd=(storage_directory / 'indexing'))
|
||||||
|
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 indexing database.')
|
||||||
|
|
||||||
|
|
||||||
def shutdown_indexing(storage_directory: Path | None=None) -> None:
|
def shutdown_indexing(storage_directory: Path | None=None) -> None:
|
||||||
|
@ -59,7 +76,15 @@ def launch_full_index(storage_directory: Path | None=None) -> None:
|
||||||
if not storage_directory:
|
if not storage_directory:
|
||||||
storage_directory = get_homedir()
|
storage_directory = get_homedir()
|
||||||
if not check_running('full_index'):
|
if not check_running('full_index'):
|
||||||
Popen(["./run_kvrocks.sh"], cwd=(storage_directory / 'full_index'))
|
process = Popen(["./run_kvrocks.sh"], cwd=(storage_directory / 'full_index'))
|
||||||
|
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 Kvrocks full indexing database.')
|
||||||
|
|
||||||
|
|
||||||
def shutdown_full_index(storage_directory: Path | None=None) -> None:
|
def shutdown_full_index(storage_directory: Path | None=None) -> None:
|
||||||
|
@ -116,7 +141,11 @@ def main() -> None:
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.start:
|
if args.start:
|
||||||
launch_all()
|
try:
|
||||||
|
launch_all()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to start some DBs: {e}")
|
||||||
|
sys.exit(1)
|
||||||
if args.stop:
|
if args.stop:
|
||||||
stop_all()
|
stop_all()
|
||||||
if not args.stop and args.status:
|
if not args.stop and args.status:
|
||||||
|
|
|
@ -10,7 +10,11 @@ def main() -> None:
|
||||||
get_homedir()
|
get_homedir()
|
||||||
print('Start backend (redis)...')
|
print('Start backend (redis)...')
|
||||||
p = run(['run_backend', '--start'])
|
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('done.')
|
||||||
print('Start archiving process...')
|
print('Start archiving process...')
|
||||||
Popen(['archiver'])
|
Popen(['archiver'])
|
||||||
|
|
|
@ -1,13 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
# set -x
|
||||||
|
|
||||||
if [ -f ../../valkey/src/valkey-server ]; then
|
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
|
../../valkey/src/valkey-server ./cache.conf
|
||||||
elif [ -f ../../redis/src/redis-server ]; then
|
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
|
../../redis/src/redis-server ./cache.conf
|
||||||
else
|
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
|
echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
|
||||||
/usr/bin/redis-server ./cache.conf
|
/usr/bin/redis-server ./cache.conf
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,13 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
# set -x
|
||||||
|
|
||||||
if [ -f ../../valkey/src/valkey-server ]; then
|
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 ./indexing.conf
|
../../valkey/src/valkey-server ./indexing.conf
|
||||||
elif [ -f ../../redis/src/redis-server ]; then
|
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 ./indexing.conf
|
../../redis/src/redis-server ./indexing.conf
|
||||||
else
|
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
|
echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
|
||||||
/usr/bin/redis-server ./indexing.conf
|
/usr/bin/redis-server ./indexing.conf
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue