-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcrash-things.sh
executable file
·61 lines (47 loc) · 1.13 KB
/
crash-things.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -e
QDRANT_DIR=${1:-./qdrant/}
QDRANT_EXEC=${2:-target/debug/qdrant}
CRASH_PROBABILITY=${3:-0.3}
RUN_TIME=${4:-300}
QDRANT_BACKUP_DIRS=( "${@:5}" )
CRASHER_LOG=crasher.log
QDRANT_LOG=../qdrant.log
CRASHER_CMD=(
cargo run --release
--
--working-dir "$QDRANT_DIR"
${QDRANT_BACKUP_DIRS[@]/#/--backup-working-dir } # this does not handle spaces 😬
--exec-path "$QDRANT_EXEC"
--crash-probability "$CRASH_PROBABILITY"
--missing-payload-check
)
echo "${CRASHER_CMD[*]}"
QDRANT__LOGGER__ON_DISK__ENABLED=true \
QDRANT__LOGGER__ON_DISK__LOG_FILE=$QDRANT_LOG \
"${CRASHER_CMD[@]}" &>"$CRASHER_LOG" &
pid=$!
echo "The PID is $pid"
function cleanup() {
if ps -p $pid >/dev/null
then
kill -KILL $pid
fi
}
trap cleanup EXIT
trap 'exit $?' ERR
trap exit INT
started=$(date +%s)
while ps -p $pid >/dev/null && (( $(date +%s) - started < RUN_TIME ))
do
sleep 10
done
if ps -p $pid >/dev/null
then
echo "The process is still running. Stopping the process..."
kill $pid
echo "OK"
else
echo "The process has unexpectedly terminated on its own. Check the logs."
exit 1
fi