From 6552b14539718f691519c9d3b8ae1b98fdfddfce Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Wed, 8 Feb 2017 11:19:20 -0800 Subject: [PATCH] [docker-teamd]: Automatically start the processes after host interfaces are created Signed-off-by: Shuotian Cheng --- dockers/docker-teamd/Dockerfile.j2 | 3 ++- dockers/docker-teamd/start.sh | 38 ++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index bff5ef11d4f5..35492bdb4670 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -19,4 +19,5 @@ COPY ["teamd.j2", "/etc/swss/teamd/"] RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT /usr/bin/config.sh && /usr/bin/start.sh +ENTRYPOINT ["/bin/bash"] +CMD ["/usr/bin/config.sh && /usr/bin/start.sh"] diff --git a/dockers/docker-teamd/start.sh b/dockers/docker-teamd/start.sh index 61251cd82d86..268217272f6e 100755 --- a/dockers/docker-teamd/start.sh +++ b/dockers/docker-teamd/start.sh @@ -2,23 +2,35 @@ TEAMD_CONF_PATH=/etc/teamd +function start_app { + if [ -d $TEAMD_CONF_PATH ]; then + for f in $TEAMD_CONF_PATH/*; do + teamd -f $f -d + done + fi + teamsyncd & +} + function clean_up { - pkill -9 teamd - pkill -9 teamsyncd - service rsyslog stop - exit + pkill -9 teamd + pkill -9 teamsyncd + service rsyslog stop + exit } trap clean_up SIGTERM SIGKILL service rsyslog start -if [ -d $TEAMD_CONF_PATH ]; then - for f in $TEAMD_CONF_PATH/*; do - teamd -f $f -d - done -fi - -teamsyncd & - -read +# Before teamd could automatically add newly created host interfaces into the +# LAG, this workaround will wait until the host interfaces are created and then +# the processes will be started. +while true; do + # Check if front-panel ports are configured + result=`echo -en "SELECT 0\nHGETALL PORT_TABLE:ConfigDone" | redis-cli | sed -n 3p` + if [ "$result" != "0" ]; then + start_app + read + fi + sleep 1 +done