[Services] Restart BGP service upon unexpected critical process exit. (#4207)

This commit is contained in:
yozhao101 2020-03-03 16:50:32 -08:00 committed by rlhui
parent c495dc3050
commit 5c8c4b2a50
14 changed files with 47 additions and 4 deletions

View File

@ -9,7 +9,6 @@ events=PROCESS_STATE_EXITED
autostart=true autostart=true
autorestart=unexpected autorestart=unexpected
[program:rsyslogd] [program:rsyslogd]
command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n" command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n"
priority=1 priority=1

View File

@ -50,6 +50,8 @@ COPY ["snmp.conf", "/etc/snmp/frr.conf"]
COPY ["TSA", "/usr/bin/TSA"] COPY ["TSA", "/usr/bin/TSA"]
COPY ["TSB", "/usr/bin/TSB"] COPY ["TSB", "/usr/bin/TSB"]
COPY ["TSC", "/usr/bin/TSC"] COPY ["TSC", "/usr/bin/TSC"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]
RUN chmod a+x /usr/bin/TSA && \ RUN chmod a+x /usr/bin/TSA && \
chmod a+x /usr/bin/TSB && \ chmod a+x /usr/bin/TSB && \
chmod a+x /usr/bin/TSC chmod a+x /usr/bin/TSC

View File

@ -0,0 +1,5 @@
zebra
staticd
bgpd
fpmsyncd
bgpcfgd

View File

@ -3,6 +3,12 @@ logfile_maxbytes=1MB
logfile_backups=2 logfile_backups=2
nodaemon=true nodaemon=true
[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
[program:start.sh] [program:start.sh]
command=/usr/bin/start.sh command=/usr/bin/start.sh
priority=1 priority=1
@ -25,7 +31,7 @@ stderr_logfile=syslog
command=/usr/sbin/rsyslogd -n command=/usr/sbin/rsyslogd -n
priority=3 priority=3
autostart=false autostart=false
autorestart=false autorestart=unexpected
startsecs=0 startsecs=0
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog

View File

@ -24,5 +24,7 @@ COPY ["start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["*.j2", "/usr/share/sonic/templates/"] COPY ["*.j2", "/usr/share/sonic/templates/"]
COPY ["daemons", "/etc/quagga/"] COPY ["daemons", "/etc/quagga/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]
ENTRYPOINT ["/usr/bin/supervisord"] ENTRYPOINT ["/usr/bin/supervisord"]

View File

@ -0,0 +1,2 @@
gobgpd
fpmsyncd

View File

@ -3,6 +3,12 @@ logfile_maxbytes=1MB
logfile_backups=2 logfile_backups=2
nodaemon=true nodaemon=true
[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
[program:start.sh] [program:start.sh]
command=/usr/bin/start.sh command=/usr/bin/start.sh
priority=1 priority=1
@ -15,7 +21,7 @@ stderr_logfile=syslog
command=/usr/sbin/rsyslogd -n command=/usr/sbin/rsyslogd -n
priority=2 priority=2
autostart=false autostart=false
autorestart=false autorestart=unexpected
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog

View File

@ -33,5 +33,7 @@ RUN rm -rf /debs ~/.cache
COPY ["bgpcfgd", "start.sh", "/usr/bin/"] COPY ["bgpcfgd", "start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["*.j2", "/usr/share/sonic/templates/"] COPY ["*.j2", "/usr/share/sonic/templates/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]
ENTRYPOINT ["/usr/bin/supervisord"] ENTRYPOINT ["/usr/bin/supervisord"]

View File

@ -0,0 +1,4 @@
zebra
bgpd
fpmsyncd
bgpcfgd

View File

@ -3,6 +3,12 @@ logfile_maxbytes=1MB
logfile_backups=2 logfile_backups=2
nodaemon=true nodaemon=true
[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected
[program:start.sh] [program:start.sh]
command=/usr/bin/start.sh command=/usr/bin/start.sh
priority=1 priority=1
@ -25,7 +31,7 @@ stderr_logfile=syslog
command=/usr/sbin/rsyslogd -n command=/usr/sbin/rsyslogd -n
priority=3 priority=3
autostart=false autostart=false
autorestart=false autorestart=unexpected
startsecs=0 startsecs=0
stdout_logfile=syslog stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog

View File

@ -3,12 +3,16 @@ Description=BGP container
Requires=updategraph.service Requires=updategraph.service
After=updategraph.service After=updategraph.service
Before=ntp-config.service Before=ntp-config.service
StartLimitIntervalSec=1200
StartLimitBurst=3
[Service] [Service]
User={{ sonicadmin_user }} User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -26,6 +26,8 @@ $(DOCKER_FPM_FRR)_RUN_OPT += --privileged -t
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw $(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw
$(DOCKER_FPM_FRR)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh $(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSA:/usr/bin/TSA $(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSA:/usr/bin/TSA
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSB:/usr/bin/TSB $(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSB:/usr/bin/TSB

View File

@ -9,3 +9,4 @@ SONIC_DOCKER_IMAGES += $(DOCKER_FPM_GOBGP)
$(DOCKER_FPM_GOBGP)_CONTAINER_NAME = bgp $(DOCKER_FPM_GOBGP)_CONTAINER_NAME = bgp
$(DOCKER_FPM_GOBGP)_RUN_OPT += --privileged -t $(DOCKER_FPM_GOBGP)_RUN_OPT += --privileged -t
$(DOCKER_FPM_GOBGP)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_FPM_GOBGP)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_GOBPG)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

View File

@ -10,4 +10,6 @@ $(DOCKER_FPM_QUAGGA)_CONTAINER_NAME = bgp
$(DOCKER_FPM_QUAGGA)_RUN_OPT += --privileged -t $(DOCKER_FPM_QUAGGA)_RUN_OPT += --privileged -t
$(DOCKER_FPM_QUAGGA)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_FPM_QUAGGA)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_QUAGGA)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
$(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh $(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh