-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_standalone.sh
67 lines (54 loc) · 1.23 KB
/
start_standalone.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
#!/bin/sh
set -o errexit
cargo build
kill_all() {
SERVICE='raft-key-value-rocks'
if [ "$(uname)" = "Darwin" ]; then
if pgrep -xq -- "${SERVICE}"; then
pkill -f "${SERVICE}"
fi
rm -r *-db || echo "no db to clean"
else
set +e # killall will error if finds no process to kill
killall "${SERVICE}"
set -e
fi
}
rpc() {
local uri=$1
local body="$2"
echo '---'" rpc(:$uri, $body)"
{
if [ ".$body" = "." ]; then
time curl --silent "127.0.0.1:$uri"
else
time curl --silent "127.0.0.1:$uri" -H "Content-Type: application/json" -d "$body"
fi
} | {
if type jq > /dev/null 2>&1; then
jq
else
cat
fi
}
echo
echo
}
export RUST_LOG=trace
export RUST_BACKTRACE=full
bin=./target/debug/s3-server
echo "Killing all running raft-key-value-rocks and cleaning up old data"
kill_all
sleep 1
if ls *-db
then
rm -r *-db || echo "no db to clean"
fi
${bin} --id 1 --http-addr 127.0.0.1:21001 --rpc-addr 127.0.0.1:22001 2>&1 > n1.log &
PID1=$!
sleep 1
echo "Server started"
echo "Initialize server as a single-node cluster"
sleep 2
echo
rpc 21001/cluster/init '{}'