[swss]: Add support for swss docker warm restart (#1982)

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
This commit is contained in:
Jipan Yang 2018-08-25 01:39:09 -07:00 committed by lguohan
parent 1157dbb4f5
commit 3f37b96de6

View File

@ -2,10 +2,29 @@
start() {
# Wait for redis server start before database clean
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]];
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]];
do sleep 1;
done
# Wait for configDB initialization
until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]];
do sleep 1;
done
SYSTEM_WARM_START=`/usr/bin/docker exec database redis-cli -n 4 HGET "WARM_RESTART|system" enable`
SWSS_WARM_START=`/usr/bin/docker exec database redis-cli -n 4 HGET "WARM_RESTART|swss" enable`
# if warm start enabled, just do swss docker start.
# Don't flush DB or try to start other modules.
if [[ "$SYSTEM_WARM_START" == "true" ]] || [[ "$SWSS_WARM_START" == "true" ]]; then
RESTART_COUNT=`redis-cli -n 6 hget "WARM_RESTART_TABLE|orchagent" restart_count`
# We have to make sure db data has not been flushed.
if [[ -n "$RESTART_COUNT" ]]; then
/usr/bin/swss.sh start
/usr/bin/swss.sh attach
return 0
fi
fi
# Flush DB
/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
/usr/bin/docker exec database redis-cli -n 1 FLUSHDB
@ -25,14 +44,22 @@ start() {
/etc/init.d/xpnet.sh start
fi
# start swss and syncd docker
/usr/bin/swss.sh start
# start swss and syncd docker
/usr/bin/swss.sh start
/usr/bin/syncd.sh start
/usr/bin/swss.sh attach
}
stop() {
/usr/bin/swss.sh stop
SYSTEM_WARM_START=`redis-cli -n 4 hget "WARM_RESTART|system" enable`
SWSS_WARM_START=`redis-cli -n 4 hget "WARM_RESTART|swss" enable`
# if warm start enabled, just stop swss docker, then return
if [[ "$SYSTEM_WARM_START" == "true" ]] || [[ "$SWSS_WARM_START" == "true" ]]; then
return 0
fi
/usr/bin/syncd.sh stop
# platform specific tasks