Skip to content

Commit 22f7dbe

Browse files
committed
Address PR review comments:
#1298 (comment)
1 parent d795b61 commit 22f7dbe

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

syncd/scripts/saidump.sh

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
#!/bin/bash
22
set -e
33

4-
function debug()
4+
save_saidump_by_rdb()
55
{
6-
/usr/bin/logger "$1"
7-
}
8-
9-
save_saidump_by_rdb() {
106
local filepath="/var/run/redis/sonic-db/database_config.json"
117

12-
#Get hostname, port, redis directory
8+
# Get hostname, port, redis directory
139
local redis_config=$(python3 -c "
1410
import json
1511
with open('$filepath') as json_file:
1612
data = json.load(json_file)
1713
print(data['INSTANCES']['redis']['hostname'], data['INSTANCES']['redis']['port'], data['INSTANCES']['redis']['unix_socket_path'])")
1814

19-
#split
15+
# split
2016
redis_config=(${redis_config// / })
2117
local hostname=${redis_config[0]}
2218
local port=${redis_config[1]}
2319
local redis_dir=`dirname ${redis_config[2]}`
24-
debug "saidump.sh: hostname:$hostname, port:$port, redis_dir:$redis_dir"
20+
logger "saidump.sh: hostname:$hostname, port:$port, redis_dir:$redis_dir"
2521

26-
debug "saidump.sh: [1] Config Redis consistency directory."
22+
logger "saidump.sh: [1] Config Redis consistency directory."
2723
redis-cli -h $hostname -p $port CONFIG SET dir $redis_dir > /dev/null
2824

29-
debug "saidump.sh: [2] SAVE."
25+
logger "saidump.sh: [2] SAVE."
3026
redis-cli -h $hostname -p $port SAVE > /dev/null
3127

32-
debug "saidump.sh: [3] Run rdb command to convert the dump files into JSON files."
28+
logger "saidump.sh: [3] Run rdb command to convert the dump files into JSON files."
3329
rdb --command json $redis_dir/dump.rdb | tee $redis_dir/dump.json > /dev/null
3430

35-
debug "saidump.sh: [4] Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump's result in standard output."
31+
logger "saidump.sh: [4] Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump's result in standard output."
3632
saidump -r $redis_dir/dump.json -m 100
3733

38-
debug "saidump.sh: [5] Clear the temporary files."
34+
logger "saidump.sh: [5] Clear the temporary files."
3935
rm -f $redis_dir/dump.rdb
4036
rm -f $redis_dir/dump.json
4137
}

0 commit comments

Comments
 (0)