Skip to content

Commit

Permalink
[scripts]: Fix issues with checking status of the DB. Use one approac…
Browse files Browse the repository at this point in the history
…h everywhere. (#1323)
  • Loading branch information
pavel-shirshov authored and lguohan committed Jan 19, 2018
1 parent 163a0e2 commit 8cfa223
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
7 changes: 2 additions & 5 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ function postStartAction()
{%- if docker_container_name != "database" %}
:
{%- else %}
while true; do
if [[ "$(docker exec -i database redis-cli ping)" =~ PONG.* ]]; then
break
fi
sleep 1
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done
{%- endif %}
{%- if docker_container_name == "snmp" %}
Expand Down
2 changes: 1 addition & 1 deletion files/build_templates/swss.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ After=nps-modules-3.16.0-4-amd64.service
[Service]
User=root
# Wait for redis server start before database clean
ExecStartPre=/bin/bash -c "while true; do if [ \"$(/usr/bin/docker exec database redis-cli ping)\" == \"PONG\" ]; then break; fi; sleep 1; done"
ExecStartPre=/bin/bash -c 'until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; do sleep 1; done'
ExecStartPre=/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
ExecStartPre=/usr/bin/docker exec database redis-cli -n 1 FLUSHDB
ExecStartPre=/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
Expand Down
7 changes: 2 additions & 5 deletions files/scripts/configdb-load.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/usr/bin/env bash

# Wait until redis starts
while true; do
if [ `redis-cli ping` == "PONG" ]; then
break
fi
sleep 1
until [[ $(redis-cli ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done

# If there is a config db dump file, load it
Expand Down

0 comments on commit 8cfa223

Please sign in to comment.