From 8f348399f591a2e94db08dbb8a459d428e68218f Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Mon, 8 May 2017 15:43:31 -0700 Subject: [PATCH] [Dockers]: Manage all Docker containers with Supervisord (#573) - Consolidate config.sh and start.sh scripts into one script (start.sh) - Solve issue #435 - All dockers now run supervisord as their ENTRYPOINT - All stdout/stderr output from processes managed by supervisord is now sent to syslog instead of their own files - Supervisord log messages are now also sent to syslog - Removed unused smartmontools package from docker-platform-monitor --- .gitignore | 9 +- dockers/docker-base/Dockerfile.j2 | 49 ++++++----- dockers/docker-base/{ => etc}/rsyslog.conf | 0 .../docker-base/etc/rsyslog.d/supervisor.conf | 8 ++ dockers/docker-basic_router/Dockerfile | 15 ++-- dockers/docker-basic_router/start.sh | 6 ++ dockers/docker-basic_router/supervisord.conf | 20 +++++ dockers/docker-database/Dockerfile.j2 | 5 +- dockers/docker-database/supervisord.conf | 12 +++ dockers/docker-dhcp-relay/Dockerfile | 17 ++-- dockers/docker-dhcp-relay/config.sh | 4 - dockers/docker-dhcp-relay/isc-dhcp-relay.sh | 19 ++++ dockers/docker-dhcp-relay/start.sh | 9 +- dockers/docker-dhcp-relay/supervisord.conf | 27 ++++++ dockers/docker-fpm-gobgp/Dockerfile.j2 | 12 ++- dockers/docker-fpm-gobgp/config.sh | 17 ---- dockers/docker-fpm-gobgp/start.sh | 26 +++++- dockers/docker-fpm-gobgp/supervisord.conf | 30 ++++++- dockers/docker-fpm-quagga/Dockerfile.j2 | 8 +- dockers/docker-fpm-quagga/config.sh | 17 ---- dockers/docker-fpm-quagga/start.sh | 26 +++++- dockers/docker-fpm-quagga/supervisord.conf | 27 ++++++ dockers/docker-lldp-sv2/Dockerfile.j2 | 11 +-- dockers/docker-lldp-sv2/config.sh | 8 -- dockers/docker-lldp-sv2/start.sh | 14 +++ dockers/docker-lldp-sv2/supervisord.conf | 30 ++++++- dockers/docker-orchagent/Dockerfile.j2 | 14 +-- dockers/docker-orchagent/config.sh | 6 -- dockers/docker-orchagent/orchagent.sh | 80 +++++++++++++++++ dockers/docker-orchagent/start.sh | 87 ++----------------- dockers/docker-orchagent/supervisord.conf | 27 ++++++ dockers/docker-platform-monitor/Dockerfile | 13 ++- dockers/docker-platform-monitor/config.sh | 12 --- dockers/docker-platform-monitor/lm-sensors.sh | 12 +++ dockers/docker-platform-monitor/start.sh | 15 ++++ .../docker-platform-monitor/supervisord.conf | 28 ++++++ dockers/docker-ptf/Dockerfile.j2 | 4 +- dockers/docker-saiserver-brcm/Dockerfile | 6 +- dockers/docker-saiserver-brcm/start.sh | 13 ++- .../docker-saiserver-brcm/supervisord.conf | 27 ++++++ dockers/docker-saiserver-cavm/Dockerfile | 19 ++-- dockers/docker-saiserver-cavm/start.sh | 14 ++- .../docker-saiserver-cavm/supervisord.conf | 27 ++++++ dockers/docker-saiserver-mlnx/Dockerfile | 32 +++---- dockers/docker-saiserver-mlnx/start.sh | 13 ++- .../docker-saiserver-mlnx/supervisord.conf | 27 ++++++ dockers/docker-snmp-sv2/Dockerfile.j2 | 13 ++- dockers/docker-snmp-sv2/config.sh | 16 ---- dockers/docker-snmp-sv2/start.sh | 18 ++++ dockers/docker-snmp-sv2/supervisord.conf | 36 ++++++-- dockers/docker-teamd/Dockerfile.j2 | 17 ++-- dockers/docker-teamd/config.sh | 12 --- dockers/docker-teamd/start.sh | 49 +++-------- dockers/docker-teamd/supervisord.conf | 27 ++++++ dockers/docker-teamd/teamd.sh | 42 +++++++++ .../docker-syncd-brcm-rpc/99-syncd.conf | 2 + .../docker-syncd-brcm-rpc/Dockerfile.j2 | 9 +- .../docker-syncd-brcm-rpc/supervisord.conf | 2 - .../broadcom/docker-syncd-brcm/Dockerfile.j2 | 8 +- platform/broadcom/docker-syncd-brcm/start.sh | 17 ++-- .../docker-syncd-brcm/supervisord.conf | 27 ++++++ platform/broadcom/docker-syncd-brcm/syncd.sh | 12 +++ .../docker-syncd-cavm-rpc/99-syncd.conf | 2 + .../docker-syncd-cavm-rpc/Dockerfile.j2 | 10 +-- .../docker-syncd-cavm-rpc/supervisord.conf | 2 - .../cavium/docker-syncd-cavm/Dockerfile.j2 | 6 +- platform/cavium/docker-syncd-cavm/start.sh | 22 +---- .../cavium/docker-syncd-cavm/supervisord.conf | 27 ++++++ platform/cavium/docker-syncd-cavm/syncd.sh | 22 +++++ .../docker-syncd-centec-rpc/99-syncd.conf | 2 + .../docker-syncd-centec-rpc/Dockerfile.j2 | 11 +-- .../docker-syncd-centec-rpc/supervisord.conf | 2 - .../centec/docker-syncd-centec/Dockerfile.j2 | 7 +- platform/centec/docker-syncd-centec/start.sh | 17 ++-- .../docker-syncd-centec/supervisord.conf | 27 ++++++ platform/centec/docker-syncd-centec/syncd.sh | 12 +++ .../docker-syncd-mlnx-rpc/99-syncd.conf | 2 + .../docker-syncd-mlnx-rpc/Dockerfile.j2 | 11 +-- .../docker-syncd-mlnx-rpc/supervisord.conf | 2 - .../mellanox/docker-syncd-mlnx/Dockerfile.j2 | 8 +- platform/mellanox/docker-syncd-mlnx/start.sh | 21 +---- .../docker-syncd-mlnx/supervisord.conf | 27 ++++++ platform/mellanox/docker-syncd-mlnx/syncd.sh | 19 ++++ 83 files changed, 989 insertions(+), 479 deletions(-) rename dockers/docker-base/{ => etc}/rsyslog.conf (100%) create mode 100644 dockers/docker-base/etc/rsyslog.d/supervisor.conf create mode 100755 dockers/docker-basic_router/start.sh create mode 100644 dockers/docker-basic_router/supervisord.conf create mode 100644 dockers/docker-database/supervisord.conf delete mode 100755 dockers/docker-dhcp-relay/config.sh create mode 100755 dockers/docker-dhcp-relay/isc-dhcp-relay.sh create mode 100644 dockers/docker-dhcp-relay/supervisord.conf delete mode 100755 dockers/docker-fpm-gobgp/config.sh delete mode 100755 dockers/docker-fpm-quagga/config.sh create mode 100644 dockers/docker-fpm-quagga/supervisord.conf delete mode 100755 dockers/docker-lldp-sv2/config.sh create mode 100755 dockers/docker-lldp-sv2/start.sh delete mode 100755 dockers/docker-orchagent/config.sh create mode 100755 dockers/docker-orchagent/orchagent.sh create mode 100644 dockers/docker-orchagent/supervisord.conf delete mode 100755 dockers/docker-platform-monitor/config.sh create mode 100755 dockers/docker-platform-monitor/lm-sensors.sh create mode 100755 dockers/docker-platform-monitor/start.sh create mode 100644 dockers/docker-platform-monitor/supervisord.conf create mode 100644 dockers/docker-saiserver-brcm/supervisord.conf create mode 100644 dockers/docker-saiserver-cavm/supervisord.conf create mode 100644 dockers/docker-saiserver-mlnx/supervisord.conf delete mode 100755 dockers/docker-snmp-sv2/config.sh create mode 100755 dockers/docker-snmp-sv2/start.sh delete mode 100755 dockers/docker-teamd/config.sh create mode 100644 dockers/docker-teamd/supervisord.conf create mode 100755 dockers/docker-teamd/teamd.sh create mode 100644 platform/broadcom/docker-syncd-brcm-rpc/99-syncd.conf delete mode 100644 platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf create mode 100644 platform/broadcom/docker-syncd-brcm/supervisord.conf create mode 100755 platform/broadcom/docker-syncd-brcm/syncd.sh create mode 100644 platform/cavium/docker-syncd-cavm-rpc/99-syncd.conf delete mode 100644 platform/cavium/docker-syncd-cavm-rpc/supervisord.conf create mode 100644 platform/cavium/docker-syncd-cavm/supervisord.conf create mode 100755 platform/cavium/docker-syncd-cavm/syncd.sh create mode 100644 platform/centec/docker-syncd-centec-rpc/99-syncd.conf delete mode 100644 platform/centec/docker-syncd-centec-rpc/supervisord.conf create mode 100644 platform/centec/docker-syncd-centec/supervisord.conf create mode 100755 platform/centec/docker-syncd-centec/syncd.sh create mode 100644 platform/mellanox/docker-syncd-mlnx-rpc/99-syncd.conf delete mode 100644 platform/mellanox/docker-syncd-mlnx-rpc/supervisord.conf create mode 100644 platform/mellanox/docker-syncd-mlnx/supervisord.conf create mode 100755 platform/mellanox/docker-syncd-mlnx/syncd.sh diff --git a/.gitignore b/.gitignore index 00f97edcec..481363b1e0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,15 +26,16 @@ src/thrift/* src/sonic-device-data/src/device/ # Autogenerated Dockerfiles +dockers/docker-base/Dockerfile +dockers/docker-config-engine/Dockerfile dockers/docker-database/Dockerfile -dockers/docker-fpm/Dockerfile +dockers/docker-fpm-frr/Dockerfile +dockers/docker-fpm-gobgp/Dockerfile +dockers/docker-fpm-quagga/Dockerfile dockers/docker-lldp-sv2/Dockerfile dockers/docker-orchagent/Dockerfile dockers/docker-snmp-sv2/Dockerfile -dockers/docker-team/Dockerfile dockers/docker-teamd/Dockerfile -dockers/docker-config-engine/Dockerfile -dockers/docker-base/Dockerfile platform/*/docker-syncd-*/Dockerfile platform/*/docker-syncd-*-rpc/Dockerfile diff --git a/dockers/docker-base/Dockerfile.j2 b/dockers/docker-base/Dockerfile.j2 index 5bdbf8b3d5..b014c20a64 100644 --- a/dockers/docker-base/Dockerfile.j2 +++ b/dockers/docker-base/Dockerfile.j2 @@ -4,36 +4,38 @@ FROM debian:jessie RUN find /usr/share/doc -depth \( -type f -o -type l \) ! -name copyright | xargs rm || true ## Clean doc directories that are empty or only contain empty directories RUN while [ -n "$(find /usr/share/doc -depth -type d -empty -print -exec rmdir {} +)" ]; do :; done -RUN rm -rf \ - /usr/share/man/* \ - /usr/share/groff/* \ - /usr/share/info/* \ - /usr/share/lintian/* \ - /usr/share/linda/* \ - /var/cache/man/* \ - /usr/share/locale/* +RUN rm -rf \ + /usr/share/man/* \ + /usr/share/groff/* \ + /usr/share/info/* \ + /usr/share/lintian/* \ + /usr/share/linda/* \ + /var/cache/man/* \ + /usr/share/locale/* ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -## Set the apt source -COPY sources.list /etc/apt/sources.list -COPY dpkg_01_drop /etc/dpkg/dpkg.cfg.d/01_drop +## Configure data sources for apt/dpkg +COPY ["sources.list", "/etc/apt/sources.list"] +COPY ["dpkg_01_drop", "/etc/dpkg/dpkg.cfg.d/01_drop"] RUN apt-get clean && apt-get update -## Pre-install the fundamental packages -RUN apt-get -y install \ - rsyslog \ - vim-tiny \ - perl \ +## Pre-install fundamental packages +RUN apt-get -y install \ + rsyslog \ + supervisor \ + vim-tiny \ + perl \ python -COPY rsyslog.conf /etc/rsyslog.conf +COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] +COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] -RUN apt-get -y purge \ - exim4 \ - exim4-base \ - exim4-config \ +RUN apt-get -y purge \ + exim4 \ + exim4-base \ + exim4-config \ exim4-daemon-light {% if docker_base_dbgs %} @@ -46,6 +48,7 @@ RUN apt-get -y install \ ## Clean up apt ## Remove /var/lib/apt/lists/*, could be obsoleted for derived images -RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y; \ - rm -rf /var/lib/apt/lists/*; \ +RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y; \ + rm -rf /var/lib/apt/lists/*; \ rm -rf /tmp/*; + diff --git a/dockers/docker-base/rsyslog.conf b/dockers/docker-base/etc/rsyslog.conf similarity index 100% rename from dockers/docker-base/rsyslog.conf rename to dockers/docker-base/etc/rsyslog.conf diff --git a/dockers/docker-base/etc/rsyslog.d/supervisor.conf b/dockers/docker-base/etc/rsyslog.d/supervisor.conf new file mode 100644 index 0000000000..e6fece313e --- /dev/null +++ b/dockers/docker-base/etc/rsyslog.d/supervisor.conf @@ -0,0 +1,8 @@ +$ModLoad imfile + +$InputFileName /var/log/supervisor/supervisord.log +$InputFileTag supervisord +$InputFileStateFile state-supervisor +$InputFileSeverity info +$InputFileFacility local0 +$InputRunFileMonitor diff --git a/dockers/docker-basic_router/Dockerfile b/dockers/docker-basic_router/Dockerfile index 7176fac14b..fa8fbd4961 100644 --- a/dockers/docker-basic_router/Dockerfile +++ b/dockers/docker-basic_router/Dockerfile @@ -5,18 +5,19 @@ MAINTAINER Xudong Wu ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -## Set the apt source +## Update apt's cache of available packages RUN apt-get clean && apt-get update COPY deps /deps -RUN dpkg -i /deps/libopennsl_*.deb; \ - dpkg -i /deps/libsaibcm_*.deb; \ +RUN dpkg -i /deps/libopennsl_*.deb; \ + dpkg -i /deps/libsaibcm_*.deb; \ apt-get -y install -f - RUN mv /deps/basic_router /usr/sbin/basic_router -ENTRYPOINT rm -f /var/run/rsyslogd.pid \ - && service rsyslog start \ - && /bin/bash +COPY ["start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-basic_router/start.sh b/dockers/docker-basic_router/start.sh new file mode 100755 index 0000000000..925076231c --- /dev/null +++ b/dockers/docker-basic_router/start.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd + diff --git a/dockers/docker-basic_router/supervisord.conf b/dockers/docker-basic_router/supervisord.conf new file mode 100644 index 0000000000..2ae8ec428b --- /dev/null +++ b/dockers/docker-basic_router/supervisord.conf @@ -0,0 +1,20 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-database/Dockerfile.j2 b/dockers/docker-database/Dockerfile.j2 index 17a416dae6..1049f5bf1b 100644 --- a/dockers/docker-database/Dockerfile.j2 +++ b/dockers/docker-database/Dockerfile.j2 @@ -32,4 +32,7 @@ RUN sed -ri 's/^(save .*$)/# \1/g; s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/ \ ' /etc/redis/redis.conf -ENTRYPOINT ["/usr/bin/redis-server", "/etc/redis/redis.conf"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-database/supervisord.conf b/dockers/docker-database/supervisord.conf new file mode 100644 index 0000000000..12a6c0a8fb --- /dev/null +++ b/dockers/docker-database/supervisord.conf @@ -0,0 +1,12 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:redis-server] +command=/usr/bin/redis-server /etc/redis/redis.conf +priority=1 +autostart=true +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-dhcp-relay/Dockerfile b/dockers/docker-dhcp-relay/Dockerfile index 315ea605f3..c3f9f29898 100644 --- a/dockers/docker-dhcp-relay/Dockerfile +++ b/dockers/docker-dhcp-relay/Dockerfile @@ -1,22 +1,21 @@ FROM docker-config-engine -## Make apt-get non-interactive +# Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -## Update APT package lists +# Update apt's cache of available packages RUN apt-get update -## Install isc-dhcp-relay Debian package +# Install isc-dhcp-relay Debian package RUN apt-get -y install isc-dhcp-relay -## Clean up +# Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs +COPY ["start.sh", "isc-dhcp-relay.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["isc-dhcp-relay.j2", "/usr/share/sonic/templates/"] -COPY ["config.sh", "/usr/bin/"] -COPY ["start.sh", "/usr/bin/"] -ENTRYPOINT /usr/bin/config.sh \ - && /usr/bin/start.sh \ - && /bin/bash +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-dhcp-relay/config.sh b/dockers/docker-dhcp-relay/config.sh deleted file mode 100755 index 99df251572..0000000000 --- a/dockers/docker-dhcp-relay/config.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay - diff --git a/dockers/docker-dhcp-relay/isc-dhcp-relay.sh b/dockers/docker-dhcp-relay/isc-dhcp-relay.sh new file mode 100755 index 0000000000..07efa35157 --- /dev/null +++ b/dockers/docker-dhcp-relay/isc-dhcp-relay.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Based off /etc/init.d/isc-dhcp-relay +# + +# Read init script configuration (interfaces the daemon should listen on +# and the DHCP server we should forward requests to.) +[ -f /etc/default/isc-dhcp-relay ] && . /etc/default/isc-dhcp-relay + +# Build command line for interfaces (will be passed to dhrelay below.) +IFCMD="" +if test "$INTERFACES" != ""; then + for I in $INTERFACES; do + IFCMD=${IFCMD}"-i "${I}" " + done +fi + +exec /usr/sbin/dhcrelay -d -q ${OPTIONS} ${IFCMD} ${SERVERS} + diff --git a/dockers/docker-dhcp-relay/start.sh b/dockers/docker-dhcp-relay/start.sh index f5bdf49396..6daff96d01 100755 --- a/dockers/docker-dhcp-relay/start.sh +++ b/dockers/docker-dhcp-relay/start.sh @@ -1,7 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay rm -f /var/run/rsyslogd.pid -service rsyslog start + +supervisorctl start rsyslogd VLAN_IFACE_NAME=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_vlan_interfaces[0]['attachto']"` @@ -11,5 +14,5 @@ until ip link show $VLAN_IFACE_NAME > /dev/null 2>&1; do done # Start the DHCP relay -service isc-dhcp-relay start +supervisorctl start isc-dhcp-relay diff --git a/dockers/docker-dhcp-relay/supervisord.conf b/dockers/docker-dhcp-relay/supervisord.conf new file mode 100644 index 0000000000..8e23c5c260 --- /dev/null +++ b/dockers/docker-dhcp-relay/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:isc-dhcp-relay] +command=/usr/bin/isc-dhcp-relay.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-fpm-gobgp/Dockerfile.j2 b/dockers/docker-fpm-gobgp/Dockerfile.j2 index 19b6caad9d..64877ee928 100644 --- a/dockers/docker-fpm-gobgp/Dockerfile.j2 +++ b/dockers/docker-fpm-gobgp/Dockerfile.j2 @@ -3,7 +3,7 @@ FROM docker-fpm-quagga ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y supervisor +RUN apt-get update COPY \ {% for deb in docker_fpm_gobgp_debs.split(' ') -%} @@ -20,12 +20,10 @@ debs/{{ deb }}{{' '}} RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs +COPY ["start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["*.j2", "/usr/share/sonic/templates/"] -COPY ["start.sh", "config.sh", "/usr/bin/"] COPY ["daemons", "/etc/quagga/"] -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -ENTRYPOINT /usr/bin/config.sh \ - && /usr/bin/start.sh \ - && /usr/bin/supervisord \ - && /bin/bash +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-fpm-gobgp/config.sh b/dockers/docker-fpm-gobgp/config.sh deleted file mode 100755 index 07aa8c33ee..0000000000 --- a/dockers/docker-fpm-gobgp/config.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -mkdir -p /etc/quagga -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/gobgpd.conf.j2 >/etc/gobgp/gobgpd.conf -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 >/etc/quagga/zebra.conf - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isolate.j2 >/usr/sbin/bgp-isolate -chown root:root /usr/sbin/bgp-isolate -chmod 0755 /usr/sbin/bgp-isolate - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/unisolate.j2 >/usr/sbin/bgp-unisolate -chown root:root /usr/sbin/bgp-unisolate -chmod 0755 /usr/sbin/bgp-unisolate - -mkdir -p /var/sonic -echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status - diff --git a/dockers/docker-fpm-gobgp/start.sh b/dockers/docker-fpm-gobgp/start.sh index 0aa3f68091..25b26179bb 100755 --- a/dockers/docker-fpm-gobgp/start.sh +++ b/dockers/docker-fpm-gobgp/start.sh @@ -1,6 +1,26 @@ -#!/bin/bash +#!/usr/bin/env bash + +mkdir -p /etc/quagga +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/gobgpd.conf.j2 > /etc/gobgp/gobgpd.conf +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate +chown root:root /usr/sbin/bgp-isolate +chmod 0755 /usr/sbin/bgp-isolate + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate +chown root:root /usr/sbin/bgp-unisolate +chmod 0755 /usr/sbin/bgp-unisolate + +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status rm -f /var/run/rsyslogd.pid -service rsyslog start + +supervisorctl start rsyslogd + +# Quagga has its own monitor process, 'watchquagga' service quagga start -fpmsyncd & + +supervisorctl start fpmsyncd + diff --git a/dockers/docker-fpm-gobgp/supervisord.conf b/dockers/docker-fpm-gobgp/supervisord.conf index 793fc5434f..18670a0847 100644 --- a/dockers/docker-fpm-gobgp/supervisord.conf +++ b/dockers/docker-fpm-gobgp/supervisord.conf @@ -1,6 +1,34 @@ [supervisord] +logfile_maxbytes=1MB +logfile_backups=2 nodaemon=true +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + [program:gobgpd] command=/usr/sbin/gobgpd -p -f /etc/gobgp/gobgpd.conf -r -priority=1 +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:fpmsyncd] +command=fpmsyncd +priority=5 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-fpm-quagga/Dockerfile.j2 b/dockers/docker-fpm-quagga/Dockerfile.j2 index 211275a2eb..2a7268a001 100644 --- a/dockers/docker-fpm-quagga/Dockerfile.j2 +++ b/dockers/docker-fpm-quagga/Dockerfile.j2 @@ -22,10 +22,10 @@ debs/{{ deb }}{{' '}} RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs +COPY ["start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["*.j2", "/usr/share/sonic/templates/"] -COPY ["start.sh", "config.sh", "/usr/bin/"] COPY ["daemons", "/etc/quagga/"] -ENTRYPOINT /usr/bin/config.sh \ - && /usr/bin/start.sh \ - && /bin/bash +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-fpm-quagga/config.sh b/dockers/docker-fpm-quagga/config.sh deleted file mode 100755 index b7fbb90344..0000000000 --- a/dockers/docker-fpm-quagga/config.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -mkdir -p /etc/quagga -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/bgpd.conf.j2 >/etc/quagga/bgpd.conf -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 >/etc/quagga/zebra.conf - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isolate.j2 >/usr/sbin/bgp-isolate -chown root:root /usr/sbin/bgp-isolate -chmod 0755 /usr/sbin/bgp-isolate - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/unisolate.j2 >/usr/sbin/bgp-unisolate -chown root:root /usr/sbin/bgp-unisolate -chmod 0755 /usr/sbin/bgp-unisolate - -mkdir -p /var/sonic -echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status - diff --git a/dockers/docker-fpm-quagga/start.sh b/dockers/docker-fpm-quagga/start.sh index 0aa3f68091..a02117dee5 100755 --- a/dockers/docker-fpm-quagga/start.sh +++ b/dockers/docker-fpm-quagga/start.sh @@ -1,6 +1,26 @@ -#!/bin/bash +#!/usr/bin/env bash + +mkdir -p /etc/quagga +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate +chown root:root /usr/sbin/bgp-isolate +chmod 0755 /usr/sbin/bgp-isolate + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate +chown root:root /usr/sbin/bgp-unisolate +chmod 0755 /usr/sbin/bgp-unisolate + +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status rm -f /var/run/rsyslogd.pid -service rsyslog start + +supervisorctl start rsyslogd + +# Quagga has its own monitor process, 'watchquagga' service quagga start -fpmsyncd & + +supervisorctl start fpmsyncd + diff --git a/dockers/docker-fpm-quagga/supervisord.conf b/dockers/docker-fpm-quagga/supervisord.conf new file mode 100644 index 0000000000..2e9d4925b9 --- /dev/null +++ b/dockers/docker-fpm-quagga/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:fpmsyncd] +command=fpmsyncd +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-lldp-sv2/Dockerfile.j2 b/dockers/docker-lldp-sv2/Dockerfile.j2 index 1910e0d79f..84002f37e7 100644 --- a/dockers/docker-lldp-sv2/Dockerfile.j2 +++ b/dockers/docker-lldp-sv2/Dockerfile.j2 @@ -11,7 +11,7 @@ COPY python-wheels /python-wheels ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y python-pip supervisor libbsd0 libevent-2.0-5 libjansson4 libwrap0 libxml2 libpci3 libperl5.20 +RUN apt-get update && apt-get install -y python-pip libbsd0 libevent-2.0-5 libjansson4 libwrap0 libxml2 libpci3 libperl5.20 # Pre-install the fundamental packages # Install Python SwSS SDK @@ -28,10 +28,11 @@ RUN pip install /python-wheels/swsssdk-2.0.1-py2-none-any.whl && \ apt-get purge -y && apt-get autoclean -y && apt-get autoremove -y && \ rm -rf /debs /python-wheels ~/.cache -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY reconfigure.sh /opt/reconfigure.sh -COPY ["config.sh", "/usr/bin/"] +COPY ["start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] +COPY ["reconfigure.sh", "/opt/"] COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"] COPY ["lldpd", "/etc/default/"] -ENTRYPOINT /usr/bin/config.sh && /usr/bin/supervisord +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-lldp-sv2/config.sh b/dockers/docker-lldp-sv2/config.sh deleted file mode 100755 index 1263cb7a51..0000000000 --- a/dockers/docker-lldp-sv2/config.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/lldpd.conf.j2 >/etc/lldpd.conf - -mkdir -p /var/sonic -echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status - -rm -f /var/run/rsyslogd.pid diff --git a/dockers/docker-lldp-sv2/start.sh b/dockers/docker-lldp-sv2/start.sh new file mode 100755 index 0000000000..ea3b7f4517 --- /dev/null +++ b/dockers/docker-lldp-sv2/start.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/lldpd.conf.j2 > /etc/lldpd.conf + +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd +supervisorctl start lldpd +supervisorctl start lldpd-conf-reload +supervisorctl start lldp-syncd + diff --git a/dockers/docker-lldp-sv2/supervisord.conf b/dockers/docker-lldp-sv2/supervisord.conf index 844348b471..62b4daebd1 100644 --- a/dockers/docker-lldp-sv2/supervisord.conf +++ b/dockers/docker-lldp-sv2/supervisord.conf @@ -1,6 +1,23 @@ [supervisord] +logfile_maxbytes=1MB +logfile_backups=2 nodaemon=true +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + [program:lldpd] # https://github.com/vincentbernat/lldpd/commit/9856f2792c301116cc4a3fcfba91b9672ee5db1f # - `-d` means to stay in foreground, log to syslog @@ -9,15 +26,22 @@ nodaemon=true # - `-dddd` means to stay in foreground, log all to console command=/usr/sbin/lldpd -d -I Ethernet*,eth* priority=100 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog [program:lldpd-conf-reload] command=/opt/reconfigure.sh priority=150 +autostart=false +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog [program:lldp-syncd] command=/usr/bin/env python2 -m lldp_syncd priority=200 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog -[program:rsyslogd] -command=/usr/sbin/rsyslogd -n -priority=1 diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 55f3b504f8..c708f30e43 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -22,14 +22,14 @@ RUN dpkg -i \ debs/{{ deb }}{{' '}} {%- endfor %} -COPY start.sh /usr/bin/start.sh -COPY config.sh /usr/bin/config.sh -COPY ipinip.json.j2 /usr/share/sonic/templates/ipinip.json.j2 -COPY mirror.json.j2 /usr/share/sonic/templates/mirror.json.j2 - ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +COPY ["start.sh", "orchagent.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] +COPY ["ipinip.json.j2", "/usr/share/sonic/templates/"] +COPY ["mirror.json.j2", "/usr/share/sonic/templates/"] + +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-orchagent/config.sh b/dockers/docker-orchagent/config.sh deleted file mode 100755 index 813dad9533..0000000000 --- a/dockers/docker-orchagent/config.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -e - -mkdir -p /etc/swss/config.d/ - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh new file mode 100755 index 0000000000..8afd8fab31 --- /dev/null +++ b/dockers/docker-orchagent/orchagent.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Exit immediately upon error +set -e + +function start_app { + orchagent $ORCHAGENT_ARGS & + portsyncd $PORTSYNCD_ARGS & + intfsyncd & + neighsyncd & + for file in $SWSSCONFIG_ARGS + do + swssconfig /etc/swss/config.d/$file + sleep 1 + done +} + +function config_acl { + if [ -f "/etc/sonic/acl.json" ]; then + mkdir -p /etc/swss/config.d/acl + rm -rf /etc/swss/config.d/acl/* + translate_acl -m /etc/sonic/minigraph.xml -o /etc/swss/config.d/acl /etc/sonic/acl.json + for filename in /etc/swss/config.d/acl/*.json; do + [ -e "$filename" ] || break + swssconfig $filename + done + fi +} + +function clean_up { + pkill -9 orchagent + pkill -9 portsyncd + pkill -9 intfsyncd + pkill -9 neighsyncd + exit +} + +trap clean_up SIGTERM SIGKILL + +HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku` + +MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'` + +ORCHAGENT_ARGS="" + +PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini" + +SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json " + +if [ "$HWSKU" == "Force10-S6000" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" + SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json " +elif [ "$HWSKU" == "Force10-S6100" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" +elif [ "$HWSKU" == "Force10-Z9100" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" +elif [ "$HWSKU" == "Arista-7050-QX32" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" + SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json " +elif [ "$HWSKU" == "Arista-7060-CX32S" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" +elif [ "$HWSKU" == "AS7512" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" +elif [ "$HWSKU" == "INGRASYS-S9100-C32" ]; then + ORCHAGENT_ARGS+="-m $MAC_ADDRESS" +elif [ "$HWSKU" == "ACS-MSN2700" ]; then + SWSSCONFIG_ARGS+="msn2700.32ports.buffers.json msn2700.32ports.qos.json " +fi + +while true; do + # Check if syncd starts + result=`echo -en "SELECT 1\nHLEN HIDDEN" | redis-cli | sed -n 2p` + if [ "$result" != "0" ]; then + start_app + config_acl + read + fi + sleep 1 +done + diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index 7a653c442e..b86a9aa1dc 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -1,84 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash -. config.sh +mkdir -p /etc/swss/config.d/ + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json export platform=`sonic-cfggen -m /etc/sonic/minigraph.xml -v platform` -function start_app { - orchagent $ORCHAGENT_ARGS & - portsyncd $PORTSYNCD_ARGS & - intfsyncd & - neighsyncd & - for file in $SWSSCONFIG_ARGS - do - swssconfig /etc/swss/config.d/$file - sleep 1 - done -} - -function config_acl { - if [ -f "/etc/sonic/acl.json" ]; then - mkdir -p /etc/swss/config.d/acl - rm -rf /etc/swss/config.d/acl/* - translate_acl -m /etc/sonic/minigraph.xml -o /etc/swss/config.d/acl /etc/sonic/acl.json - for filename in /etc/swss/config.d/acl/*.json; do - [ -e "$filename" ] || break - swssconfig $filename - done - fi -} - -function clean_up { - pkill -9 orchagent - pkill -9 portsyncd - pkill -9 intfsyncd - pkill -9 neighsyncd - service rsyslog stop - exit -} - -trap clean_up SIGTERM SIGKILL - -HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku` - -MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'` - -ORCHAGENT_ARGS="" - -PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini" - -SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json " - -if [ "$HWSKU" == "Force10-S6000" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" - SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json " -elif [ "$HWSKU" == "Force10-S6100" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" -elif [ "$HWSKU" == "Force10-Z9100" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" -elif [ "$HWSKU" == "Arista-7050-QX32" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" - SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json " -elif [ "$HWSKU" == "Arista-7060-CX32S" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" -elif [ "$HWSKU" == "AS7512" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" -elif [ "$HWSKU" == "INGRASYS-S9100-C32" ]; then - ORCHAGENT_ARGS+="-m $MAC_ADDRESS" -elif [ "$HWSKU" == "ACS-MSN2700" ]; then - SWSSCONFIG_ARGS+="msn2700.32ports.buffers.json msn2700.32ports.qos.json " -fi - rm -f /var/run/rsyslogd.pid -service rsyslog start -while true; do - # Check if syncd starts - result=`echo -en "SELECT 1\nHLEN HIDDEN" | redis-cli | sed -n 2p` - if [ "$result" != "0" ]; then - start_app - config_acl - read - fi - sleep 1 -done +supervisorctl start rsyslogd + +supervisorctl start orchagent + diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf new file mode 100644 index 0000000000..ef3a30f643 --- /dev/null +++ b/dockers/docker-orchagent/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:orchagent] +command=/usr/bin/orchagent.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-platform-monitor/Dockerfile b/dockers/docker-platform-monitor/Dockerfile index ea73830f8e..22eb4144ce 100755 --- a/dockers/docker-platform-monitor/Dockerfile +++ b/dockers/docker-platform-monitor/Dockerfile @@ -5,17 +5,14 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -y smartmontools sensord +RUN apt-get install -y sensord ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -COPY ["config.sh", "/usr/bin/"] +COPY ["start.sh", "lm-sensors.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + +ENTRYPOINT ["/usr/bin/supervisord"] -ENTRYPOINT /usr/bin/config.sh \ - && service rsyslog start \ - && service lm-sensors start \ - && service smartmontools start \ - && service sensord start \ - && /bin/bash diff --git a/dockers/docker-platform-monitor/config.sh b/dockers/docker-platform-monitor/config.sh deleted file mode 100755 index a88bdf594f..0000000000 --- a/dockers/docker-platform-monitor/config.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -mkdir -p /etc/sensors.d -if [ -e /usr/share/sonic/platform/sensors.conf ] -then - /bin/cp -rf /usr/share/sonic/platform/sensors.conf /etc/sensors.d/ -fi - -mkdir -p /var/sonic -echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status - -rm -f /var/run/rsyslogd.pid diff --git a/dockers/docker-platform-monitor/lm-sensors.sh b/dockers/docker-platform-monitor/lm-sensors.sh new file mode 100755 index 0000000000..1eafc81eeb --- /dev/null +++ b/dockers/docker-platform-monitor/lm-sensors.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Based off /etc/init.d/lm-sensors +# + +/usr/bin/sensors -s > /dev/null 2>&1 +/usr/bin/sensors > /dev/null 2>&1 + +# Currently, there is no way to run sensord in the foreground, so we +# can't use supervisord. Instead, we just start the service for now. +service sensord start + diff --git a/dockers/docker-platform-monitor/start.sh b/dockers/docker-platform-monitor/start.sh new file mode 100755 index 0000000000..0e8a6dd327 --- /dev/null +++ b/dockers/docker-platform-monitor/start.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +mkdir -p /etc/sensors.d +if [ -e /usr/share/sonic/platform/sensors.conf ]; then + /bin/cp -rf /usr/share/sonic/platform/sensors.conf /etc/sensors.d/ +fi + +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd +supervisorctl start lm-sensors + diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/supervisord.conf new file mode 100644 index 0000000000..b069c48141 --- /dev/null +++ b/dockers/docker-platform-monitor/supervisord.conf @@ -0,0 +1,28 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:lm-sensors] +command=/usr/bin/lm-sensors.sh +priority=3 +autostart=false +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index 08dd7ede16..a8459bb397 100644 --- a/dockers/docker-ptf/Dockerfile.j2 +++ b/dockers/docker-ptf/Dockerfile.j2 @@ -82,9 +82,7 @@ RUN mkdir /var/run/sshd \ && sed -i '$aUseDNS no' /etc/ssh/sshd_config \ && mkdir /root/deps -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY sshd.conf /etc/supervisor/conf.d/sshd.conf -COPY ptf_nn_agent.conf /etc/supervisor/conf.d/ptf_nn_agent.conf +COPY ["supervisord.conf", "sshd.conf", "ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] EXPOSE 22 diff --git a/dockers/docker-saiserver-brcm/Dockerfile b/dockers/docker-saiserver-brcm/Dockerfile index 3482c2068b..3a839a7a6d 100755 --- a/dockers/docker-saiserver-brcm/Dockerfile +++ b/dockers/docker-saiserver-brcm/Dockerfile @@ -17,10 +17,12 @@ RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return COPY ["deps/saiserver", "start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + COPY ["profile.ini", "portmap.ini", "/etc/sai/"] ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y; rm -rf /deps -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-saiserver-brcm/start.sh b/dockers/docker-saiserver-brcm/start.sh index 1d65e4a069..f023775f06 100755 --- a/dockers/docker-saiserver-brcm/start.sh +++ b/dockers/docker-saiserver-brcm/start.sh @@ -1,8 +1,4 @@ -#!/bin/bash - -function clean_up { - service rsyslog stop -} +#!/usr/bin/env bash start_bcm() { @@ -11,11 +7,12 @@ start_bcm() [ -e /dev/linux-kernel-bde ] || mknod /dev/linux-kernel-bde c 127 0 } -trap clean_up SIGTERM SIGKILL rm -f /var/run/rsyslogd.pid -service rsyslog start + +supervisorctl start rsyslogd start_bcm -/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini +supervisorctl start saiserver + diff --git a/dockers/docker-saiserver-brcm/supervisord.conf b/dockers/docker-saiserver-brcm/supervisord.conf new file mode 100644 index 0000000000..aa6899737e --- /dev/null +++ b/dockers/docker-saiserver-brcm/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:saiserver] +command=/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-saiserver-cavm/Dockerfile b/dockers/docker-saiserver-cavm/Dockerfile index 2ee6b8ff38..9203690ad0 100644 --- a/dockers/docker-saiserver-cavm/Dockerfile +++ b/dockers/docker-saiserver-cavm/Dockerfile @@ -1,4 +1,3 @@ - FROM docker-base RUN apt-get update \ @@ -9,22 +8,24 @@ RUN apt-get update \ COPY deps /root/deps RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; \ - dpkg_apt /root/deps/xp-tools.deb \ - && dpkg_apt /root/deps/libsai.deb \ - && dpkg_apt /root/deps/sai.deb \ - && dpkg_apt /root/deps/libthrift-0.9.3_*.deb \ + dpkg_apt /root/deps/xp-tools.deb \ + && dpkg_apt /root/deps/libsai.deb \ + && dpkg_apt /root/deps/sai.deb \ + && dpkg_apt /root/deps/libthrift-0.9.3_*.deb \ && dpkg_apt /root/deps/libnl-3-200_*.deb \ - && dpkg_apt /root/deps/libnl-genl-3-200_*.deb \ - && dpkg_apt /root/deps/libnl-route-3-200_*.deb + && dpkg_apt /root/deps/libnl-genl-3-200_*.deb \ + && dpkg_apt /root/deps/libnl-route-3-200_*.deb COPY ["deps/saiserver", "start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + COPY ["portmap.ini", "profile.ini", "/etc/sai/"] ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf deps -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-saiserver-cavm/start.sh b/dockers/docker-saiserver-cavm/start.sh index 5c31856131..16457d13e0 100755 --- a/dockers/docker-saiserver-cavm/start.sh +++ b/dockers/docker-saiserver-cavm/start.sh @@ -1,12 +1,8 @@ -#!/bin/bash - -function clean_up { - service rsyslog stop -} - -trap clean_up SIGTERM SIGKILL +#!/usr/bin/env bash rm -f /var/run/rsyslogd.pid -service rsyslog start -/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini +supervisorctl start rsyslogd + +supervisorctl start saiserver + diff --git a/dockers/docker-saiserver-cavm/supervisord.conf b/dockers/docker-saiserver-cavm/supervisord.conf new file mode 100644 index 0000000000..aa6899737e --- /dev/null +++ b/dockers/docker-saiserver-cavm/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:saiserver] +command=/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-saiserver-mlnx/Dockerfile b/dockers/docker-saiserver-mlnx/Dockerfile index 5f51f5598b..39d0fa1769 100755 --- a/dockers/docker-saiserver-mlnx/Dockerfile +++ b/dockers/docker-saiserver-mlnx/Dockerfile @@ -8,23 +8,25 @@ RUN apt-get update COPY ["deps/applibs_*.deb", "/deps/applibs-dev_*.deb", "/deps/sx-complib_*.deb", "/deps/sxd-libs_*.deb", "/deps/sx-scew_*.deb", "/deps/sx-examples_*.deb", "/deps/sx-gen-utils_*.deb", "/deps/python-sdk-api_*.deb", "/deps/iproute2_*.deb", "/deps/mlnx-sai_*.deb", "/deps/libthrift-0.9.3_*.deb", "/deps/libnl-3-200_*.deb", "/deps/libnl-genl-3-200_*.deb", "/deps/libnl-route-3-200_*.deb", "/deps/"] RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; \ - dpkg_apt /deps/applibs_*.deb \ - && dpkg_apt /deps/applibs-dev_*.deb \ - && dpkg_apt /deps/sx-complib_*.deb \ - && dpkg_apt /deps/sxd-libs_*.deb \ - && dpkg_apt /deps/sx-scew_*.deb \ - && dpkg_apt /deps/sx-examples_*.deb \ - && dpkg_apt /deps/sx-gen-utils_*.deb \ - && dpkg_apt /deps/python-sdk-api_*.deb \ - && dpkg_apt /deps/iproute2_*.deb \ - && dpkg_apt /deps/mlnx-sai_*.deb \ - && dpkg_apt /deps/libthrift-0.9.3_*.deb \ - && dpkg_apt /deps/libnl-3-200_*.deb \ - && dpkg_apt /deps/libnl-genl-3-200_*.deb \ + dpkg_apt /deps/applibs_*.deb \ + && dpkg_apt /deps/applibs-dev_*.deb \ + && dpkg_apt /deps/sx-complib_*.deb \ + && dpkg_apt /deps/sxd-libs_*.deb \ + && dpkg_apt /deps/sx-scew_*.deb \ + && dpkg_apt /deps/sx-examples_*.deb \ + && dpkg_apt /deps/sx-gen-utils_*.deb \ + && dpkg_apt /deps/python-sdk-api_*.deb \ + && dpkg_apt /deps/iproute2_*.deb \ + && dpkg_apt /deps/mlnx-sai_*.deb \ + && dpkg_apt /deps/libthrift-0.9.3_*.deb \ + && dpkg_apt /deps/libnl-3-200_*.deb \ + && dpkg_apt /deps/libnl-genl-3-200_*.deb \ && dpkg_apt /deps/libnl-route-3-200_*.deb COPY ["deps/saiserver", "start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + COPY ["profile.ini", "portmap.ini", "/etc/sai/"] COPY ["sai_2700.xml", "/usr/share/"] @@ -33,5 +35,5 @@ COPY ["sai_2700.xml", "/usr/share/"] RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /deps -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-saiserver-mlnx/start.sh b/dockers/docker-saiserver-mlnx/start.sh index e3356be120..57ee5036de 100755 --- a/dockers/docker-saiserver-mlnx/start.sh +++ b/dockers/docker-saiserver-mlnx/start.sh @@ -1,19 +1,16 @@ -#!/bin/bash - -function clean_up { - service rsyslog stop -} +#!/usr/bin/env bash start_mlnx() { [ -e /dev/sxdevs/sxcdev ] || ( mkdir -p /dev/sxdevs && mknod /dev/sxdevs/sxcdev c 231 193 ) } -trap clean_up SIGTERM SIGKILL rm -f /var/run/rsyslogd.pid -service rsyslog start + +supervisorctl start rsyslogd start_mlnx -/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini +supervisorctl start saiserver + diff --git a/dockers/docker-saiserver-mlnx/supervisord.conf b/dockers/docker-saiserver-mlnx/supervisord.conf new file mode 100644 index 0000000000..aa6899737e --- /dev/null +++ b/dockers/docker-saiserver-mlnx/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:saiserver] +command=/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-snmp-sv2/Dockerfile.j2 b/dockers/docker-snmp-sv2/Dockerfile.j2 index fed2d1b85d..73f5c257a5 100644 --- a/dockers/docker-snmp-sv2/Dockerfile.j2 +++ b/dockers/docker-snmp-sv2/Dockerfile.j2 @@ -16,15 +16,13 @@ ENV PYTHONOPTIMIZE 1 ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -# install supervisor # install libsnmp30 dependencies # install libpython3.6-dev dependencies # install pip dependencies # TODO: remove libpython3.6-dev, its and pip's dependencies if we can get pip3 directly # install subagent # clean up -RUN apt-get update && apt-get install -y supervisor \ - libperl5.20 libpci3 libwrap0 \ +RUN apt-get update && apt-get install -y libperl5.20 libpci3 libwrap0 \ libexpat1-dev \ curl gcc && \ dpkg -i \ @@ -41,11 +39,12 @@ RUN apt-get update && apt-get install -y supervisor \ find / | grep -E "__pycache__" | xargs rm -rf && \ rm -rf ~/.cache -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +COPY ["start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["*.j2", "/usr/share/sonic/templates/"] -COPY ["config.sh", "/usr/bin/"] -## Although exposing ports is not need for host net mode, keep it for possible bridge mode +## Although exposing ports is not needed for host net mode, keep it for possible bridge mode EXPOSE 161/udp 162/udp -ENTRYPOINT /usr/bin/config.sh && /usr/bin/supervisord +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-snmp-sv2/config.sh b/dockers/docker-snmp-sv2/config.sh deleted file mode 100755 index 62e8278ae4..0000000000 --- a/dockers/docker-snmp-sv2/config.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -mkdir -p /etc/ssw - -sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/sonic_version.yml -t /usr/share/sonic/templates/sysDescription.j2 >/etc/ssw/sysDescription - -mkdir -p /etc/snmp - -sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/snmp.yml -t /usr/share/sonic/templates/snmpd.conf.j2 >/etc/snmp/snmpd.conf - -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/alias_map.j2 >/etc/snmp/alias_map.json - -mkdir -p /var/sonic -echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status - -rm -f /var/run/rsyslogd.pid diff --git a/dockers/docker-snmp-sv2/start.sh b/dockers/docker-snmp-sv2/start.sh new file mode 100755 index 0000000000..7e178351b1 --- /dev/null +++ b/dockers/docker-snmp-sv2/start.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +mkdir -p /etc/ssw +sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/sonic_version.yml -t /usr/share/sonic/templates/sysDescription.j2 > /etc/ssw/sysDescription + +mkdir -p /etc/snmp +sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/snmp.yml -t /usr/share/sonic/templates/snmpd.conf.j2 > /etc/snmp/snmpd.conf +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/alias_map.j2 > /etc/snmp/alias_map.json + +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd +supervisorctl start snmpd +supervisorctl start snmp-subagent + diff --git a/dockers/docker-snmp-sv2/supervisord.conf b/dockers/docker-snmp-sv2/supervisord.conf index cf5990ec31..c4e883b3f8 100644 --- a/dockers/docker-snmp-sv2/supervisord.conf +++ b/dockers/docker-snmp-sv2/supervisord.conf @@ -1,14 +1,34 @@ [supervisord] +logfile_maxbytes=1MB +logfile_backups=2 nodaemon=true -[program:snmpd] -command=/usr/sbin/snmpd -f -LS4d -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable,inetCidrRouteTable,ip -p /run/snmpd.pid -priority=100 - -[program:snmp-subagent] -command=/usr/bin/env python3.6 -m sonic_ax_impl -priority=200 +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog [program:rsyslogd] command=/usr/sbin/rsyslogd -n -priority=1 +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:snmpd] +command=/usr/sbin/snmpd -f -LS4d -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable,inetCidrRouteTable,ip -p /run/snmpd.pid +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:snmp-subagent] +command=/usr/bin/env python3.6 -m sonic_ax_impl +priority=4 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index b3f35dd3c2..73de6bd47a 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -1,6 +1,11 @@ FROM docker-config-engine -RUN apt-get update && apt-get install -f -y libdbus-1-3 libdaemon0 libjansson4 +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +RUN apt-get install -f -y libdbus-1-3 libdaemon0 libjansson4 ## Install redis-tools dependencies ## TODO: implicitly install dependencies @@ -17,14 +22,12 @@ RUN dpkg -i \ debs/{{ deb }}{{' '}} {%- endfor %} -COPY ["start.sh", "config.sh", "/usr/bin/"] +COPY ["start.sh", "teamd.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["teamd.j2", "/usr/share/sonic/templates/"] -## Make apt-get non-interactive -ENV DEBIAN_FRONTEND=noninteractive - RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash", "-c"] -CMD ["/usr/bin/config.sh && /usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/dockers/docker-teamd/config.sh b/dockers/docker-teamd/config.sh deleted file mode 100755 index 9351966f23..0000000000 --- a/dockers/docker-teamd/config.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -mkdir -p /etc/teamd -rm -f /etc/teamd/* - -for pc in `sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_portchannels.keys() | join(' ')"`; do - sonic-cfggen -m /etc/sonic/minigraph.xml -a '{"pc":"'$pc'"}' -t /usr/share/sonic/templates/teamd.j2 >/etc/teamd/$pc.conf -done - -mkdir -p /var/sonic -echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status - diff --git a/dockers/docker-teamd/start.sh b/dockers/docker-teamd/start.sh index 5397475def..77a3ff43be 100755 --- a/dockers/docker-teamd/start.sh +++ b/dockers/docker-teamd/start.sh @@ -1,45 +1,20 @@ -#!/bin/bash +#!/usr/bin/env bash TEAMD_CONF_PATH=/etc/teamd -# Before teamd could automatically add newly created host interfaces into the -# LAG, this workaround will be needed. It will remove the obsolete files and -# net devices that are failed to be removed in the previous run. -function start_app { - # Remove *.pid and *.sock files if there are any - rm -f /var/run/teamd/* - if [ -d $TEAMD_CONF_PATH ]; then - for f in $TEAMD_CONF_PATH/*; do - # Remove netdevs if there are any - intf=`echo $f | awk -F'[/.]' '{print $4}'` - ip link del $intf - teamd -f $f -d - done - fi - teamsyncd & -} +rm -rf $TEAMD_CONF_PATH +mkdir -p $TEAMD_CONF_PATH -function clean_up { - pkill -9 teamd - pkill -9 teamsyncd - service rsyslog stop - exit -} +for pc in `sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_portchannels.keys() | join(' ')"`; do + sonic-cfggen -m /etc/sonic/minigraph.xml -a '{"pc":"'$pc'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf +done -trap clean_up SIGTERM SIGKILL +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status rm -f /var/run/rsyslogd.pid -service rsyslog start -# Before teamd could automatically add newly created host interfaces into the -# LAG, this workaround will wait until the host interfaces are created and then -# the processes will be started. -while true; do - # Check if front-panel ports are configured - result=`echo -en "SELECT 0\nHGETALL PORT_TABLE:ConfigDone" | redis-cli | sed -n 3p` - if [ "$result" == "0" ]; then - start_app - read - fi - sleep 1 -done +supervisorctl start rsyslogd + +supervisorctl start teamd + diff --git a/dockers/docker-teamd/supervisord.conf b/dockers/docker-teamd/supervisord.conf new file mode 100644 index 0000000000..3d471bd3a2 --- /dev/null +++ b/dockers/docker-teamd/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:teamd] +command=/usr/bin/teamd.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-teamd/teamd.sh b/dockers/docker-teamd/teamd.sh new file mode 100755 index 0000000000..71bc24512e --- /dev/null +++ b/dockers/docker-teamd/teamd.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +TEAMD_CONF_PATH=/etc/teamd + +# Before teamd could automatically add newly created host interfaces into the +# LAG, this workaround will be needed. It will remove the obsolete files and +# net devices that are failed to be removed in the previous run. +function start_app { + # Remove *.pid and *.sock files if there are any + rm -f /var/run/teamd/* + if [ -d $TEAMD_CONF_PATH ]; then + for f in $TEAMD_CONF_PATH/*; do + # Remove netdevs if there are any + intf=`echo $f | awk -F'[/.]' '{print $4}'` + ip link del $intf + teamd -f $f -d + done + fi + teamsyncd & +} + +function clean_up { + pkill -9 teamd + pkill -9 teamsyncd + exit +} + +trap clean_up SIGTERM SIGKILL + +# Before teamd could automatically add newly created host interfaces into the +# LAG, this workaround will wait until the host interfaces are created and then +# the processes will be started. +while true; do + # Check if front-panel ports are configured + result=`echo -en "SELECT 0\nHGETALL PORT_TABLE:ConfigDone" | redis-cli | sed -n 3p` + if [ "$result" == "0" ]; then + start_app + read + fi + sleep 1 +done + diff --git a/platform/broadcom/docker-syncd-brcm-rpc/99-syncd.conf b/platform/broadcom/docker-syncd-brcm-rpc/99-syncd.conf new file mode 100644 index 0000000000..f3b57e3b19 --- /dev/null +++ b/platform/broadcom/docker-syncd-brcm-rpc/99-syncd.conf @@ -0,0 +1,2 @@ +sysctl -w net.core.rmem_max=509430500 + diff --git a/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 index cc7c756f80..4799d7a5ab 100644 --- a/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 @@ -27,7 +27,6 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - supervisor \ && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ @@ -47,10 +46,8 @@ RUN apt-get update \ && apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y \ && rm -rf /root/deps -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY ptf_nn_agent.conf /etc/supervisor/conf.d/ptf_nn_agent.conf +COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] +COPY ["99-syncd.conf", "/etc/sysctl.d/"] -RUN sed -i "/service rsyslog start/a sysctl -w net.core.rmem_max=509430500 ; \/usr\/bin\/supervisord" /usr/bin/start.sh +ENTRYPOINT ["/usr/bin/supervisord"] -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] diff --git a/platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf b/platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf deleted file mode 100644 index daf9de259d..0000000000 --- a/platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index ffe7b6c573..af6c96c585 100755 --- a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 @@ -19,12 +19,14 @@ debs/{{ deb }}{{' '}} ## TODO: add kmod into Depends RUN apt-get install -f kmod -COPY ["debs/dsserve", "debs/bcmcmd", "start.sh", "/usr/bin/"] +COPY ["debs/dsserve", "debs/bcmcmd", "start.sh", "syncd.sh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/platform/broadcom/docker-syncd-brcm/start.sh b/platform/broadcom/docker-syncd-brcm/start.sh index 6a08b71514..96e2a91280 100755 --- a/platform/broadcom/docker-syncd-brcm/start.sh +++ b/platform/broadcom/docker-syncd-brcm/start.sh @@ -1,15 +1,8 @@ -#!/bin/bash - -function clean_up { - service syncd stop - service rsyslog stop - exit -} - -trap clean_up SIGTERM SIGKILL +#!/usr/bin/env bash rm -f /var/run/rsyslogd.pid -service rsyslog start -service syncd start -read +supervisorctl start rsyslogd + +supervisorctl start syncd + diff --git a/platform/broadcom/docker-syncd-brcm/supervisord.conf b/platform/broadcom/docker-syncd-brcm/supervisord.conf new file mode 100644 index 0000000000..71ebffee3b --- /dev/null +++ b/platform/broadcom/docker-syncd-brcm/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:syncd] +command=/usr/bin/syncd.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/platform/broadcom/docker-syncd-brcm/syncd.sh b/platform/broadcom/docker-syncd-brcm/syncd.sh new file mode 100755 index 0000000000..993cf100f2 --- /dev/null +++ b/platform/broadcom/docker-syncd-brcm/syncd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +function clean_up { + service syncd stop + exit +} + +trap clean_up SIGTERM SIGKILL + +service syncd start + +read diff --git a/platform/cavium/docker-syncd-cavm-rpc/99-syncd.conf b/platform/cavium/docker-syncd-cavm-rpc/99-syncd.conf new file mode 100644 index 0000000000..f3b57e3b19 --- /dev/null +++ b/platform/cavium/docker-syncd-cavm-rpc/99-syncd.conf @@ -0,0 +1,2 @@ +sysctl -w net.core.rmem_max=509430500 + diff --git a/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 b/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 index 2688e37833..0de427c22a 100644 --- a/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 +++ b/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 @@ -27,7 +27,6 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - supervisor \ && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ @@ -47,10 +46,7 @@ RUN apt-get update \ && apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y \ && rm -rf /root/deps -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY ptf_nn_agent.conf /etc/supervisor/conf.d/ptf_nn_agent.conf +COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] +COPY ["99-syncd.conf", "/etc/sysctl.d/"] -RUN sed -i "/service rsyslog start/a sysctl -w net.core.rmem_max=509430500 ; \/usr\/bin\/supervisord" /usr/bin/start.sh - -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/platform/cavium/docker-syncd-cavm-rpc/supervisord.conf b/platform/cavium/docker-syncd-cavm-rpc/supervisord.conf deleted file mode 100644 index daf9de259d..0000000000 --- a/platform/cavium/docker-syncd-cavm-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false diff --git a/platform/cavium/docker-syncd-cavm/Dockerfile.j2 b/platform/cavium/docker-syncd-cavm/Dockerfile.j2 index 45b71e8512..dd37db2e04 100755 --- a/platform/cavium/docker-syncd-cavm/Dockerfile.j2 +++ b/platform/cavium/docker-syncd-cavm/Dockerfile.j2 @@ -18,7 +18,8 @@ RUN dpkg -i \ debs/{{ deb }}{{' '}} {%- endfor %} -COPY ["start.sh", "/usr/bin/"] +COPY ["start.sh", "syncd.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["profile.ini", "/etc/ssw/AS7512/"] @@ -26,5 +27,4 @@ COPY ["profile.ini", "/etc/ssw/AS7512/"] RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/platform/cavium/docker-syncd-cavm/start.sh b/platform/cavium/docker-syncd-cavm/start.sh index b6c77ff235..96e2a91280 100755 --- a/platform/cavium/docker-syncd-cavm/start.sh +++ b/platform/cavium/docker-syncd-cavm/start.sh @@ -1,24 +1,8 @@ -#!/bin/bash - -export XP_ROOT=/usr/bin/ +#!/usr/bin/env bash rm -f /var/run/rsyslogd.pid -service rsyslog start -while true; do +supervisorctl start rsyslogd - # Check if redis-server starts +supervisorctl start syncd - result=$(redis-cli ping) - - if [ "$result" == "PONG" ]; then - - redis-cli FLUSHALL - syncd -p /etc/ssw/AS7512/profile.ini -N - break - - fi - - sleep 1 - -done diff --git a/platform/cavium/docker-syncd-cavm/supervisord.conf b/platform/cavium/docker-syncd-cavm/supervisord.conf new file mode 100644 index 0000000000..71ebffee3b --- /dev/null +++ b/platform/cavium/docker-syncd-cavm/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:syncd] +command=/usr/bin/syncd.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/platform/cavium/docker-syncd-cavm/syncd.sh b/platform/cavium/docker-syncd-cavm/syncd.sh new file mode 100755 index 0000000000..24767dfc6e --- /dev/null +++ b/platform/cavium/docker-syncd-cavm/syncd.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +export XP_ROOT=/usr/bin/ + +while true; do + + # Check if redis-server starts + + result=$(redis-cli ping) + + if [ "$result" == "PONG" ]; then + + redis-cli FLUSHALL + syncd -p /etc/ssw/AS7512/profile.ini -N + break + + fi + + sleep 1 + +done + diff --git a/platform/centec/docker-syncd-centec-rpc/99-syncd.conf b/platform/centec/docker-syncd-centec-rpc/99-syncd.conf new file mode 100644 index 0000000000..f3b57e3b19 --- /dev/null +++ b/platform/centec/docker-syncd-centec-rpc/99-syncd.conf @@ -0,0 +1,2 @@ +sysctl -w net.core.rmem_max=509430500 + diff --git a/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 b/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 index 2199e85d85..13a2c92cec 100644 --- a/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 +++ b/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 @@ -27,7 +27,6 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - supervisor \ && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ @@ -47,10 +46,8 @@ RUN apt-get update \ && apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y \ && rm -rf /root/deps -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY ptf_nn_agent.conf /etc/supervisor/conf.d/ptf_nn_agent.conf +COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] +COPY ["99-syncd.conf", "/etc/sysctl.d/"] + +ENTRYPOINT ["/usr/bin/supervisord"] -RUN sed -i "/service rsyslog start/a sysctl -w net.core.rmem_max=509430500 ; \/usr\/bin\/supervisord" /usr/bin/start.sh - -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] diff --git a/platform/centec/docker-syncd-centec-rpc/supervisord.conf b/platform/centec/docker-syncd-centec-rpc/supervisord.conf deleted file mode 100644 index daf9de259d..0000000000 --- a/platform/centec/docker-syncd-centec-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false diff --git a/platform/centec/docker-syncd-centec/Dockerfile.j2 b/platform/centec/docker-syncd-centec/Dockerfile.j2 index 617143215a..9e0fe52b17 100755 --- a/platform/centec/docker-syncd-centec/Dockerfile.j2 +++ b/platform/centec/docker-syncd-centec/Dockerfile.j2 @@ -19,11 +19,12 @@ debs/{{ deb }}{{' '}} ## TODO: add kmod into Depends RUN apt-get install -f kmod -COPY ["start.sh", "/usr/bin/"] +COPY ["start.sh", "syncd.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/platform/centec/docker-syncd-centec/start.sh b/platform/centec/docker-syncd-centec/start.sh index 6a08b71514..96e2a91280 100755 --- a/platform/centec/docker-syncd-centec/start.sh +++ b/platform/centec/docker-syncd-centec/start.sh @@ -1,15 +1,8 @@ -#!/bin/bash - -function clean_up { - service syncd stop - service rsyslog stop - exit -} - -trap clean_up SIGTERM SIGKILL +#!/usr/bin/env bash rm -f /var/run/rsyslogd.pid -service rsyslog start -service syncd start -read +supervisorctl start rsyslogd + +supervisorctl start syncd + diff --git a/platform/centec/docker-syncd-centec/supervisord.conf b/platform/centec/docker-syncd-centec/supervisord.conf new file mode 100644 index 0000000000..71ebffee3b --- /dev/null +++ b/platform/centec/docker-syncd-centec/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:syncd] +command=/usr/bin/syncd.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/platform/centec/docker-syncd-centec/syncd.sh b/platform/centec/docker-syncd-centec/syncd.sh new file mode 100755 index 0000000000..993cf100f2 --- /dev/null +++ b/platform/centec/docker-syncd-centec/syncd.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +function clean_up { + service syncd stop + exit +} + +trap clean_up SIGTERM SIGKILL + +service syncd start + +read diff --git a/platform/mellanox/docker-syncd-mlnx-rpc/99-syncd.conf b/platform/mellanox/docker-syncd-mlnx-rpc/99-syncd.conf new file mode 100644 index 0000000000..f3b57e3b19 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx-rpc/99-syncd.conf @@ -0,0 +1,2 @@ +sysctl -w net.core.rmem_max=509430500 + diff --git a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 index 3a4b4784ba..51fb26c00b 100644 --- a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 @@ -27,7 +27,6 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - supervisor \ && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ @@ -47,10 +46,8 @@ RUN apt-get update \ && apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y \ && rm -rf /root/deps -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY ptf_nn_agent.conf /etc/supervisor/conf.d/ptf_nn_agent.conf +COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] +COPY ["99-syncd.conf", "/etc/sysctl.d/"] + +ENTRYPOINT ["/usr/bin/supervisord"] -RUN sed -i "/service rsyslog start/a sysctl -w net.core.rmem_max=509430500 ; \/usr\/bin\/supervisord" /usr/bin/start.sh - -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] diff --git a/platform/mellanox/docker-syncd-mlnx-rpc/supervisord.conf b/platform/mellanox/docker-syncd-mlnx-rpc/supervisord.conf deleted file mode 100644 index daf9de259d..0000000000 --- a/platform/mellanox/docker-syncd-mlnx-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index cd686802f9..03257ad33e 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -18,13 +18,13 @@ RUN dpkg -i \ debs/{{ deb }}{{' '}} {%- endfor %} -COPY ["start.sh", "/usr/bin/"] -COPY ["mlnx-fw-upgrade.sh", "/usr/bin/"] +COPY ["start.sh", "syncd.sh", "mlnx-fw-upgrade.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["/debs/fw-SPC.mfa", "/etc/mlnx/"] ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/usr/bin/supervisord"] + diff --git a/platform/mellanox/docker-syncd-mlnx/start.sh b/platform/mellanox/docker-syncd-mlnx/start.sh index 3c07069ba2..96e2a91280 100755 --- a/platform/mellanox/docker-syncd-mlnx/start.sh +++ b/platform/mellanox/docker-syncd-mlnx/start.sh @@ -1,21 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash -function clean_up { - service syncd stop - service rsyslog stop - exit -} +rm -f /var/run/rsyslogd.pid -trap clean_up SIGTERM SIGKILL +supervisorctl start rsyslogd -# fw-upgrade will exit if firmware was actually upgraded or if some error -# occures -. mlnx-fw-upgrade.sh +supervisorctl start syncd -# FIXME: the script cannot trap SIGTERM signal and it exits without clean_up -# Remove rsyslogd.pid file manually so that to start the rsyslog instantly -[ -e /var/run/rsyslogd.pid ] && rm /var/run/rsyslogd.pid -service rsyslog start -service syncd start - -read diff --git a/platform/mellanox/docker-syncd-mlnx/supervisord.conf b/platform/mellanox/docker-syncd-mlnx/supervisord.conf new file mode 100644 index 0000000000..71ebffee3b --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false ; One-shot +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:syncd] +command=/usr/bin/syncd.sh +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/platform/mellanox/docker-syncd-mlnx/syncd.sh b/platform/mellanox/docker-syncd-mlnx/syncd.sh new file mode 100755 index 0000000000..ad0e0e47be --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/syncd.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +function clean_up { + service syncd stop + exit +} + +trap clean_up SIGTERM SIGKILL + +# fw-upgrade will exit if firmware was actually upgraded or if some error +# occures +. mlnx-fw-upgrade.sh + +# FIXME: the script cannot trap SIGTERM signal and it exits without clean_up +# Remove rsyslogd.pid file manually so that to start the rsyslog instantly +service syncd start + +read +