[docker-lldp-sv2]: use service dependency in supervisord to start services
This commit is contained in:
parent
267b0b7aa8
commit
1f7602b275
@ -37,6 +37,7 @@ RUN apt-get purge -y python-pip && \
|
|||||||
|
|
||||||
COPY ["docker-lldp-init.sh", "/usr/bin/"]
|
COPY ["docker-lldp-init.sh", "/usr/bin/"]
|
||||||
COPY ["start.sh", "/usr/bin/"]
|
COPY ["start.sh", "/usr/bin/"]
|
||||||
|
COPY ["waitfor_lldp_ready.sh", "/usr/bin/"]
|
||||||
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
|
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
|
||||||
COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"]
|
COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"]
|
||||||
COPY ["lldpd", "/etc/default/"]
|
COPY ["lldpd", "/etc/default/"]
|
||||||
|
@ -5,34 +5,4 @@ sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2 > /etc/lldpd.conf
|
|||||||
mkdir -p /var/sonic
|
mkdir -p /var/sonic
|
||||||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
||||||
|
|
||||||
rm -f /var/run/rsyslogd.pid
|
|
||||||
rm -f /var/run/lldpd.socket
|
rm -f /var/run/lldpd.socket
|
||||||
|
|
||||||
supervisorctl start rsyslogd
|
|
||||||
supervisorctl start lldpd
|
|
||||||
|
|
||||||
# Current lldpd version has a bug.
|
|
||||||
# When lldpd starts it is in the pause state by default
|
|
||||||
# But then it execute 'lldpcli resume' to configure and unpause itself.
|
|
||||||
# When lldpd execute lldpcli, it doesn't check the return code
|
|
||||||
# Sometimes lldpcli returns failure, but lldpd doesn't catch it
|
|
||||||
# and keeps working paused and unconfigured
|
|
||||||
#
|
|
||||||
# The fix below addresses the issue.
|
|
||||||
#
|
|
||||||
|
|
||||||
# wait until lldpd started
|
|
||||||
until [[ -e /var/run/lldpd.socket ]];
|
|
||||||
do
|
|
||||||
sleep 1;
|
|
||||||
done
|
|
||||||
|
|
||||||
# Manually try to resume lldpd, until it's successful
|
|
||||||
while /bin/true;
|
|
||||||
do
|
|
||||||
lldpcli -u /var/run/lldpd.socket -c /etc/lldpd.conf -c /etc/lldpd.d resume > /dev/null && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
supervisorctl start lldp-syncd
|
|
||||||
supervisorctl start lldpmgrd
|
|
||||||
|
@ -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 lldp
|
command=/usr/bin/supervisor-proc-exit-listener --container-name lldp
|
||||||
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=false
|
autorestart=false
|
||||||
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:lldpd]
|
[program:lldpd]
|
||||||
# https://github.com/vincentbernat/lldpd/commit/9856f2792c301116cc4a3fcfba91b9672ee5db1f
|
# https://github.com/vincentbernat/lldpd/commit/9856f2792c301116cc4a3fcfba91b9672ee5db1f
|
||||||
@ -41,6 +53,19 @@ 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:waitfor_lldp_ready]
|
||||||
|
command=/usr/bin/waitfor_lldp_ready.sh
|
||||||
|
priority=3
|
||||||
|
autostart=false
|
||||||
|
autorestart=false
|
||||||
|
startsecs=0
|
||||||
|
stdout_logfile=syslog
|
||||||
|
stderr_logfile=syslog
|
||||||
|
dependent_startup=true
|
||||||
|
dependent_startup_wait_for=lldpd:running
|
||||||
|
|
||||||
[program:lldp-syncd]
|
[program:lldp-syncd]
|
||||||
command=/usr/bin/env python2 -m lldp_syncd
|
command=/usr/bin/env python2 -m lldp_syncd
|
||||||
@ -49,6 +74,8 @@ 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=waitfor_lldp_ready:exited
|
||||||
|
|
||||||
[program:lldpmgrd]
|
[program:lldpmgrd]
|
||||||
command=/usr/bin/lldpmgrd
|
command=/usr/bin/lldpmgrd
|
||||||
@ -57,3 +84,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=lldp-syncd:running
|
||||||
|
24
dockers/docker-lldp-sv2/waitfor_lldp_ready.sh
Executable file
24
dockers/docker-lldp-sv2/waitfor_lldp_ready.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Current lldpd version has a bug.
|
||||||
|
# When lldpd starts it is in the pause state by default
|
||||||
|
# But then it execute 'lldpcli resume' to configure and unpause itself.
|
||||||
|
# When lldpd execute lldpcli, it doesn't check the return code
|
||||||
|
# Sometimes lldpcli returns failure, but lldpd doesn't catch it
|
||||||
|
# and keeps working paused and unconfigured
|
||||||
|
#
|
||||||
|
# The fix below addresses the issue.
|
||||||
|
#
|
||||||
|
|
||||||
|
# wait until lldpd started
|
||||||
|
until [[ -e /var/run/lldpd.socket ]];
|
||||||
|
do
|
||||||
|
sleep 1;
|
||||||
|
done
|
||||||
|
|
||||||
|
# Manually try to resume lldpd, until it's successful
|
||||||
|
while /bin/true;
|
||||||
|
do
|
||||||
|
lldpcli -u /var/run/lldpd.socket -c /etc/lldpd.conf -c /etc/lldpd.d resume > /dev/null && break
|
||||||
|
sleep 1
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user