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

This commit is contained in:
Guohan Lu 2020-05-16 00:09:16 +00:00 committed by lguohan
parent 7ea6d9dc8f
commit b8da6c3588
4 changed files with 76 additions and 77 deletions

View File

@ -59,8 +59,9 @@ RUN apt-get clean -y && \
rm -rf /debs rm -rf /debs
COPY ["files/arp_update", "/usr/bin"] COPY ["files/arp_update", "/usr/bin"]
COPY ["arp_update.conf", "/usr/share/sonic/templates/"]
COPY ["enable_counters.py", "/usr/bin"] COPY ["enable_counters.py", "/usr/bin"]
COPY ["start.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"] COPY ["docker-init.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor/"] COPY ["critical_processes", "/etc/supervisor/"]
@ -68,4 +69,4 @@ COPY ["critical_processes", "/etc/supervisor/"]
## Copy all Jinja2 template files into the templates folder ## Copy all Jinja2 template files into the templates folder
COPY ["*.j2", "/usr/share/sonic/templates/"] COPY ["*.j2", "/usr/share/sonic/templates/"]
ENTRYPOINT ["/usr/bin/supervisord"] ENTRYPOINT ["/usr/bin/docker-init.sh"]

View File

@ -0,0 +1,9 @@
[program:arp_update]
command=/usr/bin/arp_update
priority=7
autostart=false
autorestart=unexpected
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=swssconfig:exited

View File

@ -11,40 +11,10 @@ if [ -x /usr/share/sonic/hwsku/hwsku-init ]; then
/usr/share/sonic/hwsku/hwsku-init /usr/share/sonic/hwsku/hwsku-init
fi fi
export platform=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
rm -f /var/run/rsyslogd.pid
supervisorctl start rsyslogd
supervisorctl start orchagent
supervisorctl start restore_neighbors
supervisorctl start portsyncd
supervisorctl start neighsyncd
supervisorctl start swssconfig
supervisorctl start vrfmgrd
supervisorctl start vlanmgrd
supervisorctl start intfmgrd
supervisorctl start portmgrd
supervisorctl start buffermgrd
supervisorctl start enable_counters
supervisorctl start nbrmgrd
supervisorctl start vxlanmgrd
# Start arp_update when VLAN exists # Start arp_update when VLAN exists
VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'` VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
if [ "$VLAN" != "" ]; then if [ "$VLAN" != "" ]; then
supervisorctl start arp_update cp /usr/share/sonic/templates/arp_update.conf /etc/supervisord/conf.d/
fi fi
exec /usr/bin/supervisord

View File

@ -3,27 +3,28 @@ 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 swss command=/usr/bin/supervisor-proc-exit-listener --container-name swss
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:orchagent] [program:orchagent]
command=/usr/bin/orchagent.sh command=/usr/bin/orchagent.sh
@ -32,22 +33,20 @@ 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=rsyslogd:running
[program:portsyncd] [program:restore_neighbors]
command=/usr/bin/portsyncd command=/usr/bin/restore_neighbors.py
priority=4 priority=4
autostart=false autostart=false
autorestart=false autorestart=false
startsecs=0
startretries=0
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true
[program:neighsyncd] dependent_startup_wait_for=orchagent:running
command=/usr/bin/neighsyncd
priority=5
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:swssconfig] [program:swssconfig]
command=/usr/bin/swssconfig.sh command=/usr/bin/swssconfig.sh
@ -58,14 +57,28 @@ startretries=0
startsecs=0 startsecs=0
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=orchagent:running
[program:arp_update] [program:portsyncd]
command=/usr/bin/arp_update command=/usr/bin/portsyncd
priority=7 priority=4
autostart=false autostart=false
autorestart=unexpected autorestart=false
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=swssconfig:exited
[program:neighsyncd]
command=/usr/bin/neighsyncd
priority=5
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=swssconfig:exited
[program:vlanmgrd] [program:vlanmgrd]
command=/usr/bin/vlanmgrd command=/usr/bin/vlanmgrd
@ -74,6 +87,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=swssconfig:exited
[program:intfmgrd] [program:intfmgrd]
command=/usr/bin/intfmgrd command=/usr/bin/intfmgrd
@ -82,6 +97,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=swssconfig:exited
[program:portmgrd] [program:portmgrd]
command=/usr/bin/portmgrd command=/usr/bin/portmgrd
@ -90,6 +107,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=swssconfig:exited
[program:buffermgrd] [program:buffermgrd]
command=/usr/bin/buffermgrd -l /usr/share/sonic/hwsku/pg_profile_lookup.ini command=/usr/bin/buffermgrd -l /usr/share/sonic/hwsku/pg_profile_lookup.ini
@ -98,14 +117,8 @@ autostart=false
autorestart=false autorestart=false
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true
[program:enable_counters] dependent_startup_wait_for=swssconfig:exited
command=/usr/bin/enable_counters.py
priority=12
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:vrfmgrd] [program:vrfmgrd]
command=/usr/bin/vrfmgrd command=/usr/bin/vrfmgrd
@ -114,16 +127,8 @@ autostart=false
autorestart=false autorestart=false
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true
[program:restore_neighbors] dependent_startup_wait_for=swssconfig:exited
command=/usr/bin/restore_neighbors.py
priority=14
autostart=false
autorestart=false
startsecs=0
startretries=0
stdout_logfile=syslog
stderr_logfile=syslog
[program:nbrmgrd] [program:nbrmgrd]
command=/usr/bin/nbrmgrd command=/usr/bin/nbrmgrd
@ -132,6 +137,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=swssconfig:exited
[program:vxlanmgrd] [program:vxlanmgrd]
command=/usr/bin/vxlanmgrd command=/usr/bin/vxlanmgrd
@ -140,3 +147,15 @@ 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=swssconfig:exited
[program:enable_counters]
command=/usr/bin/enable_counters.py
priority=12
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=swssconfig:exited