-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathrun.sh
executable file
·68 lines (55 loc) · 2.11 KB
/
run.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
62
63
64
65
66
67
68
#!/usr/bin/env bash
# A script to run Redis with RedisTimeSeries module.
# Supports running under release and debug modes, using locally-built
# Redis server instance path and may run under gdb.
MODULE_RELEASE_PATH=$PWD/bin/linux-x64-release/redistimeseries.so
MODULE_DEBUG_PATH=$PWD/bin/linux-x64-debug/redistimeseries.so
REDIS_ARGUMENTS="--enable-debug-command yes"
REDIS_GLOBAL_PATH=redis-server
DEBUGGER_SCRIPT="gdb --args"
VALGRIND="valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s"
function launch() {
local redis_path=$1
local timeseries_module_path=$2
local redis_arguments="$3 $4"
$redis_path --loadmodule $timeseries_module_path $redis_arguments
}
function parse_args_and_launch() {
local redis_path=$REDIS_GLOBAL_PATH
local timeseries_module_path=$MODULE_RELEASE_PATH
local redis_arguments=$REDIS_ARGUMENTS
local prefix=""
while getopts 'dDs:l:vh' opt; do
case "$opt" in
d)
echo "Setting up to run against the debug binaries."
timeseries_module_path=$MODULE_DEBUG_PATH
;;
D)
echo "Setting up to run through a debugger."
timeseries_module_path=$MODULE_DEBUG_PATH
prefix="${DEBUGGER_SCRIPT}"
;;
s)
arg="$OPTARG"
echo "Setting up to run a custom redis server: '${OPTARG}'"
redis_path=${OPTARG}
;;
l)
arg="$OPTARG"
echo "Setting up a custom timeseries library path: '${OPTARG}'"
timeseries_module_path="${OPTARG}/libredistimeseries.so"
;;
v)
echo "Setting up to run through valgrind."
prefix="${VALGRIND}"
;;
?|h)
printf "Usage: $(basename $0) [-d] [-D] [-v] [-s custom-redis-path] [-l custom-library-path]\nArguments:\n\t-d\tUse debug binaries\n\t-D\tRun in debugger\n\t-v\tRun via valgrind\n\t-s\tSpecify custom redis server\n\t-l\tSpecify custom library path\n\nExample: $(basename $0) -d -s ../redis/src/redis-server\n"
exit 1
;;
esac
done
launch "${prefix} ${redis_path}" $timeseries_module_path $redis_arguments
}
parse_args_and_launch $@