[docker-syncd-vs]: use service dependency in supervisord to start services

This commit is contained in:
Guohan Lu 2020-05-16 15:33:46 +00:00 committed by lguohan
parent 2e42a4ba0f
commit ecde1fe1aa
2 changed files with 24 additions and 41 deletions

View File

@ -1,30 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PLATFORM_DIR=/usr/share/sonic/platform
HWSKU_DIR=/usr/share/sonic/hwsku 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/ mkdir -p /etc/sai.d/
# Create/Copy the sai.profile to /etc/sai.d/sai.profile # 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 cp $HWSKU_DIR/sai.profile /etc/sai.d/sai.profile
fi fi
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

View File

@ -3,27 +3,39 @@ logfile_maxbytes=1MB
logfile_backups=2 logfile_backups=2
nodaemon=true 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] [eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name syncd command=/usr/bin/supervisor-proc-exit-listener --container-name syncd
events=PROCESS_STATE_EXITED events=PROCESS_STATE_EXITED
autostart=true autostart=true
autorestart=unexpected autorestart=unexpected
[program:start.sh]
command=/usr/bin/start.sh
priority=1
autostart=true
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:rsyslogd] [program:rsyslogd]
command=/usr/sbin/rsyslogd -n command=/usr/sbin/rsyslogd -n -iNONE
priority=2 priority=1
autostart=false autostart=false
autorestart=unexpected autorestart=unexpected
stdout_logfile=syslog stdout_logfile=syslog
stderr_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] [program:syncd]
command=/usr/bin/syncd_start.sh command=/usr/bin/syncd_start.sh
@ -32,3 +44,5 @@ autostart=false
autorestart=false autorestart=false
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited