[docker-syncd-brcm]: use service dependency in supervisord to start services
This commit is contained in:
parent
ecde1fe1aa
commit
bb40300cad
@ -21,7 +21,7 @@ debs/
|
|||||||
## TODO: add kmod into Depends
|
## TODO: add kmod into Depends
|
||||||
RUN apt-get install -yf kmod
|
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
|
RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd
|
||||||
|
|
||||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||||
|
@ -1,43 +1,12 @@
|
|||||||
#!/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
|
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
|
# Remove stale files if they exist
|
||||||
rm -f /var/run/rsyslogd.pid
|
|
||||||
rm -f ${SYNCD_SOCKET_FILE}
|
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
|
||||||
@ -48,11 +17,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 && ! -f /var/warmboot/warm-starting ]]; then
|
|
||||||
wait_syncd
|
|
||||||
supervisorctl start ledinit
|
|
||||||
fi
|
|
||||||
|
37
platform/broadcom/docker-syncd-brcm/start_led.sh
Executable file
37
platform/broadcom/docker-syncd-brcm/start_led.sh
Executable 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"
|
@ -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,12 +44,16 @@ 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
|
||||||
|
|
||||||
[program:ledinit]
|
[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
|
priority=4
|
||||||
autostart=false
|
autostart=false
|
||||||
autorestart=false
|
autorestart=false
|
||||||
startsecs=0
|
startsecs=0
|
||||||
stdout_logfile=syslog
|
stdout_logfile=syslog
|
||||||
stderr_logfile=syslog
|
stderr_logfile=syslog
|
||||||
|
dependent_startup=true
|
||||||
|
dependent_startup_wait_for=syncd:running
|
||||||
|
Loading…
Reference in New Issue
Block a user