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

This commit is contained in:
Guohan Lu 2020-05-16 15:43:23 +00:00 committed by lguohan
parent ecde1fe1aa
commit bb40300cad
4 changed files with 65 additions and 51 deletions

View File

@ -21,7 +21,7 @@ debs/
## TODO: add kmod into Depends
RUN apt-get install -yf kmod
COPY ["files/dsserve", "files/bcmcmd", "start.sh", "bcmsh", "/usr/bin/"]
COPY ["files/dsserve", "files/bcmcmd", "start.sh", "start_led.sh", "bcmsh", "/usr/bin/"]
RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]

View File

@ -1,43 +1,12 @@
#!/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
counter=0
while true; do
/usr/bin/bcmcmd -t 1 "show unit" | grep BCM >/dev/null 2>&1
rv=$?
if [ $rv -eq 0 ]; then
break
fi
counter=$((counter+1))
if [ $counter -ge 60 ]; then
echo "syncd is not ready to take commands after $counter re-tries; Exiting!"
break
fi
sleep 1
done
}
# 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
@ -48,11 +17,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 && ! -f /var/warmboot/warm-starting ]]; then
wait_syncd
supervisorctl start ledinit
fi

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
PLATFORM_DIR=/usr/share/sonic/platform
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
counter=0
while true; do
/usr/bin/bcmcmd -t 1 "show unit" | grep BCM >/dev/null 2>&1
rv=$?
if [ $rv -eq 0 ]; then
break
fi
counter=$((counter+1))
if [ $counter -ge 60 ]; then
echo "syncd is not ready to take commands after $counter re-tries; Exiting!"
break
fi
sleep 1
done
}
# If this platform has an initialization file for the Broadcom LED microprocessor, load it
if [[ -r ${PLATFORM_DIR}/led_proc_init.soc && ! -f /var/warmboot/warm-starting ]]; then
wait_syncd
fi
/usr/bin/bcmcmd -t 60 "rcload /usr/share/sonic/platform/led_proc_init.soc"

View File

@ -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,12 +44,16 @@ autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited
[program:ledinit]
command=/usr/bin/bcmcmd -t 60 "rcload /usr/share/sonic/platform/led_proc_init.soc"
command=/usr/bin/start_led.sh
priority=4
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=syncd:running