From f49a7c5e14e4eefde743cb3a5d051b5a654a4266 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 3 May 2017 21:15:44 +0000 Subject: [PATCH 01/17] Install supervisor in docker-base; Use rsyslog to monitor supervisor log file --- dockers/docker-base/Dockerfile.j2 | 44 ++++++++++--------- dockers/docker-base/{ => etc}/rsyslog.conf | 0 .../docker-base/etc/rsyslog.d/supervisor.conf | 8 ++++ 3 files changed, 31 insertions(+), 21 deletions(-) rename dockers/docker-base/{ => etc}/rsyslog.conf (100%) create mode 100644 dockers/docker-base/etc/rsyslog.d/supervisor.conf diff --git a/dockers/docker-base/Dockerfile.j2 b/dockers/docker-base/Dockerfile.j2 index 5bdbf8b3d5ae..cc7b66ea742c 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 +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 \ +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,6 @@ 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 000000000000..e6fece313efc --- /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 From 0846b299867fd941de23363c7e499f1f64cf698d Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 06:44:42 +0000 Subject: [PATCH 02/17] Use supervisor to manage processes in all currently-used dockers - Also now installing supervisor package in docker-base so that supervisor is available in all docker containers and can be used as a standard, so removed supervisor installation from dockers built on top of docker-base. - Capped supervisor log max filesize to 1MB and max of 2 rotated files. We shouldn't need more because rsyslog should be constantly monitoring changes to these files and appending them to syslog. - Also some unrelated minor cleanup in docker-ptf Dockerfile --- dockers/docker-base/Dockerfile.j2 | 5 +- dockers/docker-basic_router/Dockerfile | 15 ++-- dockers/docker-basic_router/start.sh | 6 ++ dockers/docker-basic_router/supervisord.conf | 18 ++++ 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 | 25 ++++++ 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 | 28 +++++- 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 | 25 ++++++ 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 | 28 +++++- dockers/docker-orchagent/Dockerfile.j2 | 14 +-- dockers/docker-orchagent/config.sh | 6 -- dockers/docker-orchagent/orchagent.sh | 80 +++++++++++++++++ dockers/docker-orchagent/start.sh | 85 ++----------------- dockers/docker-orchagent/supervisord.conf | 25 ++++++ dockers/docker-platform-monitor/Dockerfile | 11 +-- dockers/docker-platform-monitor/config.sh | 12 --- dockers/docker-platform-monitor/lm-sensors.sh | 8 ++ dockers/docker-platform-monitor/start.sh | 17 ++++ .../docker-platform-monitor/supervisord.conf | 40 +++++++++ dockers/docker-ptf/Dockerfile.j2 | 4 +- 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 | 28 ++++-- dockers/docker-teamd/Dockerfile.j2 | 17 ++-- dockers/docker-teamd/config.sh | 12 --- dockers/docker-teamd/start.sh | 55 ++++-------- dockers/docker-teamd/supervisord.conf | 25 ++++++ dockers/docker-teamd/teamd.sh | 42 +++++++++ 43 files changed, 590 insertions(+), 293 deletions(-) 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 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 diff --git a/dockers/docker-base/Dockerfile.j2 b/dockers/docker-base/Dockerfile.j2 index cc7b66ea742c..b014c20a6401 100644 --- a/dockers/docker-base/Dockerfile.j2 +++ b/dockers/docker-base/Dockerfile.j2 @@ -16,12 +16,12 @@ RUN rm -rf \ ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive -## Set the apt source +## 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 +## Pre-install fundamental packages RUN apt-get -y install \ rsyslog \ supervisor \ @@ -51,3 +51,4 @@ RUN apt-get -y install \ 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-basic_router/Dockerfile b/dockers/docker-basic_router/Dockerfile index 7176fac14b3b..fa8fbd496172 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 000000000000..925076231ccf --- /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 000000000000..48b7f8ca73f9 --- /dev/null +++ b/dockers/docker-basic_router/supervisord.conf @@ -0,0 +1,18 @@ +[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 + +[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 17a416dae69d..1049f5bf1bfe 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 000000000000..12a6c0a8fb1b --- /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 315ea605f3ee..c3f9f298983e 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 99df251572d5..000000000000 --- 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 000000000000..7a49eec6cd5c --- /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 -- -q $OPTIONS $IFCMD $SERVERS + diff --git a/dockers/docker-dhcp-relay/start.sh b/dockers/docker-dhcp-relay/start.sh index f5bdf49396d3..6daff96d0129 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 000000000000..8effbadbd642 --- /dev/null +++ b/dockers/docker-dhcp-relay/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 19b6caad9d99..64877ee9286d 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 07aa8c33eea1..000000000000 --- 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 0aa3f68091a1..25b26179bb58 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 793fc5434f80..bc6d1d7f233b 100644 --- a/dockers/docker-fpm-gobgp/supervisord.conf +++ b/dockers/docker-fpm-gobgp/supervisord.conf @@ -1,6 +1,32 @@ [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 + +[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 211275a2eb16..2a7268a0019e 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 b7fbb90344e9..000000000000 --- 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 0aa3f68091a1..a02117dee5ef 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 000000000000..eaf710da36fc --- /dev/null +++ b/dockers/docker-fpm-quagga/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 1910e0d79fe3..84002f37e7ee 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 1263cb7a5154..000000000000 --- 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 000000000000..ea3b7f45175c --- /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 844348b471b6..8018cd2097b8 100644 --- a/dockers/docker-lldp-sv2/supervisord.conf +++ b/dockers/docker-lldp-sv2/supervisord.conf @@ -1,6 +1,21 @@ [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 + +[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 +24,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 55f3b504f820..c708f30e439b 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 813dad9533c5..000000000000 --- 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 000000000000..8afd8fab314b --- /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 7a653c442ef8..b86a9aa1dc57 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/ -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` +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 -MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'` - -ORCHAGENT_ARGS="" - -PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini" +export platform=`sonic-cfggen -m /etc/sonic/minigraph.xml -v platform` -SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json " +rm -f /var/run/rsyslogd.pid -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 +supervisorctl start rsyslogd -rm -f /var/run/rsyslogd.pid -service rsyslog start +supervisorctl start orchagent -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/supervisord.conf b/dockers/docker-orchagent/supervisord.conf new file mode 100644 index 000000000000..44ce00a2af92 --- /dev/null +++ b/dockers/docker-orchagent/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 ea73830f8e6c..6d9b2a1dd6a2 100755 --- a/dockers/docker-platform-monitor/Dockerfile +++ b/dockers/docker-platform-monitor/Dockerfile @@ -11,11 +11,8 @@ RUN apt-get install -y smartmontools sensord 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 a88bdf594f95..000000000000 --- 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 000000000000..db19ebeaf3d1 --- /dev/null +++ b/dockers/docker-platform-monitor/lm-sensors.sh @@ -0,0 +1,8 @@ +#!/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 + diff --git a/dockers/docker-platform-monitor/start.sh b/dockers/docker-platform-monitor/start.sh new file mode 100755 index 000000000000..d7b36374ff98 --- /dev/null +++ b/dockers/docker-platform-monitor/start.sh @@ -0,0 +1,17 @@ +#!/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 +supervisorctl start smartd +supervisorctl start sensord + diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/supervisord.conf new file mode 100644 index 000000000000..caab906ffde7 --- /dev/null +++ b/dockers/docker-platform-monitor/supervisord.conf @@ -0,0 +1,40 @@ +[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 + +[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 + +[program:smartd] +command=/usr/sbin/smartd -d +priority=4 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:sensord] +command=/usr/sbin/sensord -f daemon +priority=5 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index 08dd7ede16fb..a8459bb39781 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-snmp-sv2/Dockerfile.j2 b/dockers/docker-snmp-sv2/Dockerfile.j2 index fed2d1b85d58..73f5c257a5c4 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 62e8278ae41b..000000000000 --- 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 000000000000..24499f6f5858 --- /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 snmp +supervisorctl start snmp-subagent + diff --git a/dockers/docker-snmp-sv2/supervisord.conf b/dockers/docker-snmp-sv2/supervisord.conf index cf5990ec31e8..0addebd00b5c 100644 --- a/dockers/docker-snmp-sv2/supervisord.conf +++ b/dockers/docker-snmp-sv2/supervisord.conf @@ -1,14 +1,32 @@ [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 + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +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=100 +priority=3 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog [program:snmp-subagent] command=/usr/bin/env python3.6 -m sonic_ax_impl -priority=200 +priority=4 +autostart=false +stdout_logfile=syslog +stderr_logfile=syslog -[program:rsyslogd] -command=/usr/sbin/rsyslogd -n -priority=1 diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index b3f35dd3c2e5..73de6bd47a78 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 9351966f233f..000000000000 --- 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 5397475defb7..77a3ff43be85 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 & -} - -function clean_up { - pkill -9 teamd - pkill -9 teamsyncd - service rsyslog stop - exit -} - -trap clean_up SIGTERM SIGKILL +rm -rf $TEAMD_CONF_PATH +mkdir -p $TEAMD_CONF_PATH -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 +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 + +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 teamd + diff --git a/dockers/docker-teamd/supervisord.conf b/dockers/docker-teamd/supervisord.conf new file mode 100644 index 000000000000..671a9a32e5a1 --- /dev/null +++ b/dockers/docker-teamd/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 000000000000..71bc24512ebc --- /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 + From 6b86bad05de57c401cc8f6fafa802a2baf6673a1 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 21:59:01 +0000 Subject: [PATCH 03/17] Supervisorize docker-syncd-brcm --- .../broadcom/docker-syncd-brcm/Dockerfile.j2 | 8 +++--- platform/broadcom/docker-syncd-brcm/start.sh | 15 +++-------- .../docker-syncd-brcm/supervisord.conf | 25 +++++++++++++++++++ platform/broadcom/docker-syncd-brcm/syncd.sh | 12 +++++++++ 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 platform/broadcom/docker-syncd-brcm/supervisord.conf create mode 100755 platform/broadcom/docker-syncd-brcm/syncd.sh diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index ffe7b6c57397..af6c96c585d0 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 6a08b7151432..96e2a9128081 100755 --- a/platform/broadcom/docker-syncd-brcm/start.sh +++ b/platform/broadcom/docker-syncd-brcm/start.sh @@ -1,15 +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 -rm -f /var/run/rsyslogd.pid -service rsyslog start -service syncd start +supervisorctl start syncd -read diff --git a/platform/broadcom/docker-syncd-brcm/supervisord.conf b/platform/broadcom/docker-syncd-brcm/supervisord.conf new file mode 100644 index 000000000000..aac27f1fdfa6 --- /dev/null +++ b/platform/broadcom/docker-syncd-brcm/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 000000000000..993cf100f2f0 --- /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 From b78d21c0e11aaf1979abac3496bb36a9259c07ed Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 22:28:21 +0000 Subject: [PATCH 04/17] Supervisorize docker-syncd-cavm --- .../cavium/docker-syncd-cavm/Dockerfile.j2 | 6 ++--- platform/cavium/docker-syncd-cavm/start.sh | 22 +++------------- .../cavium/docker-syncd-cavm/supervisord.conf | 25 +++++++++++++++++++ platform/cavium/docker-syncd-cavm/syncd.sh | 22 ++++++++++++++++ 4 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 platform/cavium/docker-syncd-cavm/supervisord.conf create mode 100755 platform/cavium/docker-syncd-cavm/syncd.sh diff --git a/platform/cavium/docker-syncd-cavm/Dockerfile.j2 b/platform/cavium/docker-syncd-cavm/Dockerfile.j2 index 45b71e85129c..dd37db2e04d2 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 b6c77ff235b5..96e2a9128081 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 - - # 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 +supervisorctl start rsyslogd - sleep 1 +supervisorctl start syncd -done diff --git a/platform/cavium/docker-syncd-cavm/supervisord.conf b/platform/cavium/docker-syncd-cavm/supervisord.conf new file mode 100644 index 000000000000..aac27f1fdfa6 --- /dev/null +++ b/platform/cavium/docker-syncd-cavm/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 000000000000..24767dfc6e0a --- /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 + From ac7ad4a495f1cb00218ccab63037bb2fa1e83bc8 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 22:32:52 +0000 Subject: [PATCH 05/17] Supervisorize docker-syncd-centec --- .../centec/docker-syncd-centec/Dockerfile.j2 | 7 +++--- platform/centec/docker-syncd-centec/start.sh | 15 +++-------- .../docker-syncd-centec/supervisord.conf | 25 +++++++++++++++++++ platform/centec/docker-syncd-centec/syncd.sh | 12 +++++++++ 4 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 platform/centec/docker-syncd-centec/supervisord.conf create mode 100755 platform/centec/docker-syncd-centec/syncd.sh diff --git a/platform/centec/docker-syncd-centec/Dockerfile.j2 b/platform/centec/docker-syncd-centec/Dockerfile.j2 index 617143215a4d..9e0fe52b174e 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 6a08b7151432..96e2a9128081 100755 --- a/platform/centec/docker-syncd-centec/start.sh +++ b/platform/centec/docker-syncd-centec/start.sh @@ -1,15 +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 -rm -f /var/run/rsyslogd.pid -service rsyslog start -service syncd start +supervisorctl start syncd -read diff --git a/platform/centec/docker-syncd-centec/supervisord.conf b/platform/centec/docker-syncd-centec/supervisord.conf new file mode 100644 index 000000000000..aac27f1fdfa6 --- /dev/null +++ b/platform/centec/docker-syncd-centec/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 000000000000..993cf100f2f0 --- /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 From 45b8295ab6fa77acda35e3ab813b588a0d0378af Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 22:39:03 +0000 Subject: [PATCH 06/17] Supervisorize docker-syncd-mlnx --- .../mellanox/docker-syncd-mlnx/Dockerfile.j2 | 8 +++--- platform/mellanox/docker-syncd-mlnx/start.sh | 21 +++------------- .../docker-syncd-mlnx/supervisord.conf | 25 +++++++++++++++++++ platform/mellanox/docker-syncd-mlnx/syncd.sh | 19 ++++++++++++++ 4 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 platform/mellanox/docker-syncd-mlnx/supervisord.conf create mode 100755 platform/mellanox/docker-syncd-mlnx/syncd.sh diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index cd686802f907..03257ad33e2f 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 3c07069ba26e..96e2a9128081 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 000000000000..aac27f1fdfa6 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/supervisord.conf @@ -0,0 +1,25 @@ +[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 + +[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 000000000000..ad0e0e47be87 --- /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 + From 57d82c482b6f6a35ec25d3ff0630ad31a6070caa Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 22:49:45 +0000 Subject: [PATCH 07/17] Fix typo --- dockers/docker-snmp-sv2/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-snmp-sv2/start.sh b/dockers/docker-snmp-sv2/start.sh index 24499f6f5858..7e178351b159 100755 --- a/dockers/docker-snmp-sv2/start.sh +++ b/dockers/docker-snmp-sv2/start.sh @@ -13,6 +13,6 @@ echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status rm -f /var/run/rsyslogd.pid supervisorctl start rsyslogd -supervisorctl start snmp +supervisorctl start snmpd supervisorctl start snmp-subagent From c88f03c0b26722d9ba4eea2ad60f896a7d4e3aff Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 23:19:53 +0000 Subject: [PATCH 08/17] Supervisorize docker-syncd-brcm-rpc --- platform/broadcom/docker-syncd-brcm-rpc/99-syncd.conf | 2 ++ platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 | 9 +++------ platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 platform/broadcom/docker-syncd-brcm-rpc/99-syncd.conf delete mode 100644 platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf 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 000000000000..f3b57e3b1964 --- /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 cc7c756f801c..4799d7a5ab31 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 daf9de259d77..000000000000 --- a/platform/broadcom/docker-syncd-brcm-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false From 5f5c016fea4786352c9cafbf52c1b5977ecaca71 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 23:37:20 +0000 Subject: [PATCH 09/17] Supervisorize docker-syncd-cavm-rpc --- platform/cavium/docker-syncd-cavm-rpc/99-syncd.conf | 2 ++ platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 | 10 +++------- platform/cavium/docker-syncd-cavm-rpc/supervisord.conf | 2 -- 3 files changed, 5 insertions(+), 9 deletions(-) create mode 100644 platform/cavium/docker-syncd-cavm-rpc/99-syncd.conf delete mode 100644 platform/cavium/docker-syncd-cavm-rpc/supervisord.conf 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 000000000000..f3b57e3b1964 --- /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 2688e37833e1..0de427c22a27 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 daf9de259d77..000000000000 --- a/platform/cavium/docker-syncd-cavm-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false From 46e4ff1274261a28adf315b2448e7c73c79548b5 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 23:38:40 +0000 Subject: [PATCH 10/17] Supervisorize docker-syncd-centec-rpc --- platform/centec/docker-syncd-centec-rpc/99-syncd.conf | 2 ++ platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 | 11 ++++------- .../centec/docker-syncd-centec-rpc/supervisord.conf | 2 -- 3 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 platform/centec/docker-syncd-centec-rpc/99-syncd.conf delete mode 100644 platform/centec/docker-syncd-centec-rpc/supervisord.conf 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 000000000000..f3b57e3b1964 --- /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 2199e85d85d1..13a2c92cecee 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 daf9de259d77..000000000000 --- a/platform/centec/docker-syncd-centec-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false From 1a0a945eebd7ff5405b4851de92114ae8f82d31a Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 May 2017 23:39:56 +0000 Subject: [PATCH 11/17] Supervisorize docker-syncd-mlnx-rpc --- platform/mellanox/docker-syncd-mlnx-rpc/99-syncd.conf | 2 ++ platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 | 11 ++++------- .../mellanox/docker-syncd-mlnx-rpc/supervisord.conf | 2 -- 3 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 platform/mellanox/docker-syncd-mlnx-rpc/99-syncd.conf delete mode 100644 platform/mellanox/docker-syncd-mlnx-rpc/supervisord.conf 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 000000000000..f3b57e3b1964 --- /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 3a4b4784babd..51fb26c00b11 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 daf9de259d77..000000000000 --- a/platform/mellanox/docker-syncd-mlnx-rpc/supervisord.conf +++ /dev/null @@ -1,2 +0,0 @@ -[supervisord] -nodaemon=false From 40b0d34931ba03828cd63a405ccd386ad1cd8770 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 May 2017 00:42:14 +0000 Subject: [PATCH 12/17] Sensord cannot be run in foreground, so just start service for now --- dockers/docker-platform-monitor/lm-sensors.sh | 4 ++++ dockers/docker-platform-monitor/start.sh | 1 - dockers/docker-platform-monitor/supervisord.conf | 7 ------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dockers/docker-platform-monitor/lm-sensors.sh b/dockers/docker-platform-monitor/lm-sensors.sh index db19ebeaf3d1..1eafc81eeb63 100755 --- a/dockers/docker-platform-monitor/lm-sensors.sh +++ b/dockers/docker-platform-monitor/lm-sensors.sh @@ -6,3 +6,7 @@ /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 index d7b36374ff98..3d5ffae8fc6b 100755 --- a/dockers/docker-platform-monitor/start.sh +++ b/dockers/docker-platform-monitor/start.sh @@ -13,5 +13,4 @@ rm -f /var/run/rsyslogd.pid supervisorctl start rsyslogd supervisorctl start lm-sensors supervisorctl start smartd -supervisorctl start sensord diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/supervisord.conf index caab906ffde7..176aa9c14eee 100644 --- a/dockers/docker-platform-monitor/supervisord.conf +++ b/dockers/docker-platform-monitor/supervisord.conf @@ -31,10 +31,3 @@ autostart=false stdout_logfile=syslog stderr_logfile=syslog -[program:sensord] -command=/usr/sbin/sensord -f daemon -priority=5 -autostart=false -stdout_logfile=syslog -stderr_logfile=syslog - From 75e67fa62a243827ea2e3559da63372f0fbd4bcb Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 May 2017 01:52:39 +0000 Subject: [PATCH 13/17] Fix exec command --- dockers/docker-dhcp-relay/isc-dhcp-relay.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-dhcp-relay/isc-dhcp-relay.sh b/dockers/docker-dhcp-relay/isc-dhcp-relay.sh index 7a49eec6cd5c..53530906a5dd 100755 --- a/dockers/docker-dhcp-relay/isc-dhcp-relay.sh +++ b/dockers/docker-dhcp-relay/isc-dhcp-relay.sh @@ -15,5 +15,5 @@ if test "$INTERFACES" != ""; then done fi -exec /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS +exec /usr/sbin/dhcrelay -q ${OPTIONS} ${IFCMD} ${SERVERS} From c6b0e80a8d0a2f1131054d2cacda084ab8c53e3f Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 May 2017 18:20:44 +0000 Subject: [PATCH 14/17] Log stdout and stderr from start.sh to syslog instead of their own files --- dockers/docker-basic_router/supervisord.conf | 2 ++ dockers/docker-dhcp-relay/supervisord.conf | 2 ++ dockers/docker-fpm-gobgp/supervisord.conf | 2 ++ dockers/docker-fpm-quagga/supervisord.conf | 2 ++ dockers/docker-lldp-sv2/supervisord.conf | 2 ++ dockers/docker-orchagent/supervisord.conf | 2 ++ dockers/docker-platform-monitor/supervisord.conf | 2 ++ dockers/docker-snmp-sv2/supervisord.conf | 2 ++ dockers/docker-teamd/supervisord.conf | 2 ++ platform/broadcom/docker-syncd-brcm/supervisord.conf | 2 ++ platform/cavium/docker-syncd-cavm/supervisord.conf | 2 ++ platform/centec/docker-syncd-centec/supervisord.conf | 2 ++ platform/mellanox/docker-syncd-mlnx/supervisord.conf | 2 ++ 13 files changed, 26 insertions(+) diff --git a/dockers/docker-basic_router/supervisord.conf b/dockers/docker-basic_router/supervisord.conf index 48b7f8ca73f9..2ae8ec428b3e 100644 --- a/dockers/docker-basic_router/supervisord.conf +++ b/dockers/docker-basic_router/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-dhcp-relay/supervisord.conf b/dockers/docker-dhcp-relay/supervisord.conf index 8effbadbd642..8e23c5c260ce 100644 --- a/dockers/docker-dhcp-relay/supervisord.conf +++ b/dockers/docker-dhcp-relay/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-fpm-gobgp/supervisord.conf b/dockers/docker-fpm-gobgp/supervisord.conf index bc6d1d7f233b..18670a084703 100644 --- a/dockers/docker-fpm-gobgp/supervisord.conf +++ b/dockers/docker-fpm-gobgp/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-fpm-quagga/supervisord.conf b/dockers/docker-fpm-quagga/supervisord.conf index eaf710da36fc..2e9d4925b985 100644 --- a/dockers/docker-fpm-quagga/supervisord.conf +++ b/dockers/docker-fpm-quagga/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-lldp-sv2/supervisord.conf b/dockers/docker-lldp-sv2/supervisord.conf index 8018cd2097b8..62b4daebd107 100644 --- a/dockers/docker-lldp-sv2/supervisord.conf +++ b/dockers/docker-lldp-sv2/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 44ce00a2af92..ef3a30f64358 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/supervisord.conf index 176aa9c14eee..8808a161711b 100644 --- a/dockers/docker-platform-monitor/supervisord.conf +++ b/dockers/docker-platform-monitor/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-snmp-sv2/supervisord.conf b/dockers/docker-snmp-sv2/supervisord.conf index 0addebd00b5c..c4e883b3f8f0 100644 --- a/dockers/docker-snmp-sv2/supervisord.conf +++ b/dockers/docker-snmp-sv2/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/dockers/docker-teamd/supervisord.conf b/dockers/docker-teamd/supervisord.conf index 671a9a32e5a1..3d471bd3a222 100644 --- a/dockers/docker-teamd/supervisord.conf +++ b/dockers/docker-teamd/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/platform/broadcom/docker-syncd-brcm/supervisord.conf b/platform/broadcom/docker-syncd-brcm/supervisord.conf index aac27f1fdfa6..71ebffee3bf4 100644 --- a/platform/broadcom/docker-syncd-brcm/supervisord.conf +++ b/platform/broadcom/docker-syncd-brcm/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/platform/cavium/docker-syncd-cavm/supervisord.conf b/platform/cavium/docker-syncd-cavm/supervisord.conf index aac27f1fdfa6..71ebffee3bf4 100644 --- a/platform/cavium/docker-syncd-cavm/supervisord.conf +++ b/platform/cavium/docker-syncd-cavm/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/platform/centec/docker-syncd-centec/supervisord.conf b/platform/centec/docker-syncd-centec/supervisord.conf index aac27f1fdfa6..71ebffee3bf4 100644 --- a/platform/centec/docker-syncd-centec/supervisord.conf +++ b/platform/centec/docker-syncd-centec/supervisord.conf @@ -8,6 +8,8 @@ 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 diff --git a/platform/mellanox/docker-syncd-mlnx/supervisord.conf b/platform/mellanox/docker-syncd-mlnx/supervisord.conf index aac27f1fdfa6..71ebffee3bf4 100644 --- a/platform/mellanox/docker-syncd-mlnx/supervisord.conf +++ b/platform/mellanox/docker-syncd-mlnx/supervisord.conf @@ -8,6 +8,8 @@ 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 From 425482ded65ba0824194b04e1f8826ae01b0f291 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 May 2017 21:49:04 +0000 Subject: [PATCH 15/17] Supervisorize docker-saiserver-brcm, docker-saiserver-cavm, docker-saiserver-mlnx; update .gitignore --- .gitignore | 9 +++--- 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 | 12 +++---- .../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 ++++++++++++++++ 10 files changed, 131 insertions(+), 54 deletions(-) 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 diff --git a/.gitignore b/.gitignore index 00f97edcec97..481363b1e00a 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-saiserver-brcm/Dockerfile b/dockers/docker-saiserver-brcm/Dockerfile index 3482c2068bc5..3a839a7a6df0 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 1d65e4a069e7..f023775f0674 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 000000000000..aa6899737e8d --- /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 2ee6b8ff38cd..9203690ad02a 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 5c3185613184..16457d13e03a 100755 --- a/dockers/docker-saiserver-cavm/start.sh +++ b/dockers/docker-saiserver-cavm/start.sh @@ -1,12 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash -function clean_up { - service rsyslog stop -} +rm -f /var/run/rsyslogd.pid -trap clean_up SIGTERM SIGKILL +supervisorctl start rsyslogd -rm -f /var/run/rsyslogd.pid -service rsyslog start +supervisorctl start saiserver -/usr/bin/saiserver -p /etc/sai/profile.ini -f /etc/sai/portmap.ini diff --git a/dockers/docker-saiserver-cavm/supervisord.conf b/dockers/docker-saiserver-cavm/supervisord.conf new file mode 100644 index 000000000000..aa6899737e8d --- /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 5f51f5598b18..39d0fa176987 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 e3356be12025..57ee5036ded3 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 000000000000..aa6899737e8d --- /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 + From e6f1f4319bc081069d193e475cdb17d1d0b36bfb Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 May 2017 22:08:38 +0000 Subject: [PATCH 16/17] Remove S.M.A.R.T. monitoring tools from docker-platform-monitor --- dockers/docker-platform-monitor/Dockerfile | 2 +- dockers/docker-platform-monitor/start.sh | 1 - dockers/docker-platform-monitor/supervisord.conf | 7 ------- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/dockers/docker-platform-monitor/Dockerfile b/dockers/docker-platform-monitor/Dockerfile index 6d9b2a1dd6a2..22eb4144cec5 100755 --- a/dockers/docker-platform-monitor/Dockerfile +++ b/dockers/docker-platform-monitor/Dockerfile @@ -5,7 +5,7 @@ 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 diff --git a/dockers/docker-platform-monitor/start.sh b/dockers/docker-platform-monitor/start.sh index 3d5ffae8fc6b..0e8a6dd32760 100755 --- a/dockers/docker-platform-monitor/start.sh +++ b/dockers/docker-platform-monitor/start.sh @@ -12,5 +12,4 @@ rm -f /var/run/rsyslogd.pid supervisorctl start rsyslogd supervisorctl start lm-sensors -supervisorctl start smartd diff --git a/dockers/docker-platform-monitor/supervisord.conf b/dockers/docker-platform-monitor/supervisord.conf index 8808a161711b..b069c48141ac 100644 --- a/dockers/docker-platform-monitor/supervisord.conf +++ b/dockers/docker-platform-monitor/supervisord.conf @@ -26,10 +26,3 @@ autorestart=false ; One-shot stdout_logfile=syslog stderr_logfile=syslog -[program:smartd] -command=/usr/sbin/smartd -d -priority=4 -autostart=false -stdout_logfile=syslog -stderr_logfile=syslog - From 471333261bfc5dbda916d29ae997db878bda9a99 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 May 2017 22:14:48 +0000 Subject: [PATCH 17/17] Force dhcrelay to run in foreground --- dockers/docker-dhcp-relay/isc-dhcp-relay.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-dhcp-relay/isc-dhcp-relay.sh b/dockers/docker-dhcp-relay/isc-dhcp-relay.sh index 53530906a5dd..07efa351578f 100755 --- a/dockers/docker-dhcp-relay/isc-dhcp-relay.sh +++ b/dockers/docker-dhcp-relay/isc-dhcp-relay.sh @@ -15,5 +15,5 @@ if test "$INTERFACES" != ""; then done fi -exec /usr/sbin/dhcrelay -q ${OPTIONS} ${IFCMD} ${SERVERS} +exec /usr/sbin/dhcrelay -d -q ${OPTIONS} ${IFCMD} ${SERVERS}