From e5616f236d480fdc8116ec0db5ccaafc8d197c7c Mon Sep 17 00:00:00 2001 From: lguohan Date: Thu, 9 Feb 2017 06:52:20 -0800 Subject: [PATCH] [swss]: Wait for redis server start before database clean (#281) picked this change from sonic-mgmt repo. https://github.com/Azure/sonic-mgmt/pull/110 --- files/build_templates/swss.service.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/files/build_templates/swss.service.j2 b/files/build_templates/swss.service.j2 index b7e34335f5fe..f60ef6712dd8 100644 --- a/files/build_templates/swss.service.j2 +++ b/files/build_templates/swss.service.j2 @@ -5,6 +5,8 @@ After=database.service [Service] User={{ sonicadmin_user }} +# 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=/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