-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_valkey.sh
executable file
·53 lines (45 loc) · 1.23 KB
/
start_valkey.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
#!/bin/bash
# This command will start valkey for both the CI and for local testing
if ! command -v docker &> /dev/null; then
echo >&2 "Docker is required but was not found."
exit 1
fi
ARGS=()
PORT=6379
SENTINEL=0
while (($# > 0)); do
case "$1" in
--sentinel)
# setup a valkey sentinel
CONF=$(mktemp -d)
ARGS=("${ARGS[@]}" "$CONF/valkey.conf" --sentinel)
PORT=26379
SENTINEL=1
cat > "$CONF/valkey.conf" <<EOF
sentinel monitor default_service 127.0.0.1 6379 1
sentinel down-after-milliseconds default_service 3200
sentinel failover-timeout default_service 10000
sentinel parallel-syncs default_service 1
EOF
chmod 777 "$CONF"
chmod 666 "$CONF/valkey.conf"
shift
;;
esac
done
# open a unix socket for socket tests
if [[ $SENTINEL == 0 ]]; then
# make sure the file doesn't already exist
rm -f /tmp/valkey.sock
ARGS=("${ARGS[@]}" --unixsocket /tmp/valkey.sock --unixsocketperm 777)
fi
# start valkey
sudo docker run \
--health-cmd "valkey-cli -p $PORT:$PORT ping" \
--health-interval 10s \
--health-retries 5 \
--health-timeout 5s \
--network host \
--user $(id -u):$(id -g) \
--volume /tmp:/tmp \
--detach valkey/valkey valkey-server "${ARGS[@]}" --save ""