From ecde1fe1aad4d2460c383069659547a25b0dee3a Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sat, 16 May 2020 15:33:46 +0000 Subject: [PATCH] [docker-syncd-vs]: use service dependency in supervisord to start services --- platform/vs/docker-syncd-vs/start.sh | 31 ------------------ platform/vs/docker-syncd-vs/supervisord.conf | 34 ++++++++++++++------ 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/platform/vs/docker-syncd-vs/start.sh b/platform/vs/docker-syncd-vs/start.sh index 98c7d9c15a..40178f13e0 100755 --- a/platform/vs/docker-syncd-vs/start.sh +++ b/platform/vs/docker-syncd-vs/start.sh @@ -1,30 +1,7 @@ #!/usr/bin/env bash -PLATFORM_DIR=/usr/share/sonic/platform HWSKU_DIR=/usr/share/sonic/hwsku -SYNCD_SOCKET_FILE=/var/run/sswsyncd/sswsyncd.socket - -# Function: wait until syncd has created the socket for bcmcmd to connect to -wait_syncd() { - while true; do - if [ -e ${SYNCD_SOCKET_FILE} ]; then - break - fi - sleep 1 - done - - # wait until bcm sdk is ready to get a request - sleep 3 -} - - -# Remove stale files if they exist -rm -f /var/run/rsyslogd.pid -rm -f ${SYNCD_SOCKET_FILE} - -supervisorctl start rsyslogd - mkdir -p /etc/sai.d/ # Create/Copy the sai.profile to /etc/sai.d/sai.profile @@ -35,11 +12,3 @@ else cp $HWSKU_DIR/sai.profile /etc/sai.d/sai.profile fi fi - -supervisorctl start syncd - -# If this platform has an initialization file for the Broadcom LED microprocessor, load it -if [ -r ${PLATFORM_DIR}/led_proc_init.soc ]; then - wait_syncd - supervisorctl start ledinit -fi diff --git a/platform/vs/docker-syncd-vs/supervisord.conf b/platform/vs/docker-syncd-vs/supervisord.conf index 0c6285d46a..b097d1aa8c 100644 --- a/platform/vs/docker-syncd-vs/supervisord.conf +++ b/platform/vs/docker-syncd-vs/supervisord.conf @@ -3,27 +3,39 @@ logfile_maxbytes=1MB logfile_backups=2 nodaemon=true +[eventlistener:dependent-startup] +command=python -m supervisord_dependent_startup +autostart=true +autorestart=unexpected +startretries=0 +exitcodes=0,3 +events=PROCESS_STATE + [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name syncd events=PROCESS_STATE_EXITED autostart=true autorestart=unexpected -[program:start.sh] -command=/usr/bin/start.sh -priority=1 -autostart=true -autorestart=false -stdout_logfile=syslog -stderr_logfile=syslog - [program:rsyslogd] -command=/usr/sbin/rsyslogd -n -priority=2 +command=/usr/sbin/rsyslogd -n -iNONE +priority=1 autostart=false autorestart=unexpected stdout_logfile=syslog stderr_logfile=syslog +dependent_startup=true + +[program:start] +command=/usr/bin/start.sh +priority=2 +autostart=false +autorestart=false +startsecs=0 +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running [program:syncd] command=/usr/bin/syncd_start.sh @@ -32,3 +44,5 @@ autostart=false autorestart=false stdout_logfile=syslog stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=start:exited