From d89d146bcd3859951d663ef6cc84fc9be3393167 Mon Sep 17 00:00:00 2001 From: chandi Date: Thu, 14 May 2020 18:59:22 +0200 Subject: [PATCH] core: switch from systemd to supervisord --- docker-compose.yml | 12 ---------- mod/core/Dockerfile | 21 +++++++----------- mod/core/dummy.service | 9 -------- mod/core/entrypoint.sh | 4 +--- mod/core/prefix-log | 16 ++++++++++++++ mod/core/supervisord.conf | 46 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 37 deletions(-) delete mode 100644 mod/core/dummy.service create mode 100755 mod/core/prefix-log create mode 100644 mod/core/supervisord.conf diff --git a/docker-compose.yml b/docker-compose.yml index c04e72d..f6f9d2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,24 +6,12 @@ services: restart: unless-stopped depends_on: - redis - cap_add: - - SYS_NICE # for realtime scheduling - - SYS_ADMIN # for systemd environment: DOMAIN: ${DOMAIN} - EXTERNAL_IP: ${EXTERNAL_IP} SHARED_SECRET: ${SHARED_SECRET} WELCOME_FOOTER: ${WELCOME_FOOTER} - container: docker - tmpfs: - - /run - - /run/lock - - /tmp:exec,mode=777 volumes: - bigbluebutton:/var/bigbluebutton - - /sys/fs/cgroup:/sys/fs/cgroup:ro # for systemd - - ./conf/sip_profiles:/opt/freeswitch/conf/sip_profiles/external - - ./conf/dialplan_public:/opt/freeswitch/conf/dialplan/public_docker network_mode: host freeswitch: diff --git a/mod/core/Dockerfile b/mod/core/Dockerfile index d14dc7d..49b088f 100644 --- a/mod/core/Dockerfile +++ b/mod/core/Dockerfile @@ -10,10 +10,9 @@ ENV DEBIAN_FRONTEND noninteractive ENV container docker ENV DOCKERIZE_VERSION v0.6.1 -RUN apt-get update && apt-get install -y software-properties-common language-pack-en wget +RUN apt-get update && apt-get install -y software-properties-common language-pack-en wget apt-utils RUN update-locale LANG=en_US.UTF-8 RUN LC_CTYPE=C.UTF-8 add-apt-repository ppa:rmescandon/yq -RUN apt-get install -y --no-install-recommends apt-utils # install dockerize RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ @@ -24,7 +23,7 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI # RUN apt-get install -y tcpdump telnet htop vim # -- Install Dependencies -RUN apt-get install -y systemd apt-transport-https equivs libreoffice haveged ttf-liberation net-tools +RUN apt-get install -y supervisor apt-transport-https equivs libreoffice haveged ttf-liberation net-tools # bbb repo & packages RUN LC_CTYPE=C.UTF-8 add-apt-repository ppa:bigbluebutton/support @@ -38,9 +37,6 @@ RUN equivs-control redis-server.control \ && dpkg -i /*.deb \ && rm /*.deb -# -- create dummy service to avoid start up errors -COPY dummy.service /etc/systemd/system/redis-server.service - RUN apt-get update && apt-get install -y bbb-web \ bbb-fsesl-akka bbb-apps-akka bbb-transcode-akka bbb-apps \ bbb-apps-video bbb-apps-screenshare bbb-apps-video-broadcast @@ -49,16 +45,9 @@ RUN apt-get update && apt-get install -y bbb-web \ # https://github.com/bigbluebutton/bigbluebutton/issues/8959 RUN sed -i 's|securerandom.source=file:/dev/random|securerandom.source=file:/dev/urandom|g' /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security -# -- Disable unneeded services -RUN find /etc/systemd/ | grep wants | xargs -r -n 1 basename | grep service | grep -v networking | grep -v tty | xargs -r -n 1 -I __ systemctl disable __ -RUN systemctl disable systemd-journal-flush systemd-update-utmp.service -RUN systemctl enable red5 bbb-apps-akka bbb-transcode-akka bbb-fsesl-akka bbb-web # bbb-rap-caption-inbox - # -- fix directory permissions RUN chown bigbluebutton:bigbluebutton /var/bigbluebutton -COPY entrypoint.sh /entrypoint.sh - # -- copy configuration files COPY red5.properties /usr/share/red5/conf/red5.properties COPY bigbluebutton.properties /usr/share/red5/webapps/bigbluebutton/WEB-INF/bigbluebutton.properties @@ -70,6 +59,12 @@ COPY bbb-apps-akka/application.conf /usr/share/bbb-apps-akka/conf/application.co COPY bbb-fsesl-akka/application.conf /etc/bbb-fsesl-akka/application.conf COPY web-run.sh /usr/share/bbb-web/run-prod.sh +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +COPY entrypoint.sh /entrypoint.sh + +COPY prefix-log /usr/local/bin/prefix-log +RUN mkdir -p /var/log/supervisor + ENTRYPOINT ["/entrypoint.sh"] CMD [] diff --git a/mod/core/dummy.service b/mod/core/dummy.service deleted file mode 100644 index 72d0825..0000000 --- a/mod/core/dummy.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=dummy - -[Service] -ExecStart=/bin/sleep 30d -ExecReload=/bin/echo reload - -[Install] -WantedBy=multi-user.target diff --git a/mod/core/entrypoint.sh b/mod/core/entrypoint.sh index 6962ce1..b4cd40b 100755 --- a/mod/core/entrypoint.sh +++ b/mod/core/entrypoint.sh @@ -1,7 +1,5 @@ #!/bin/bash -# print logs to stdout/stderr as soon as systemd is started -sh -c 'sleep 5 && journalctl -f' & # generate bbb folders mkdir -p /var/bigbluebutton/recording/raw @@ -19,4 +17,4 @@ mkdir -p /var/bigbluebutton/unpublished dockerize \ -template /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties.tmpl:/usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties \ -template /usr/share/bbb-apps-akka/conf/application.conf.tmpl:/usr/share/bbb-apps-akka/conf/application.conf \ - /bin/systemd --system --unit=multi-user.target \ No newline at end of file + /usr/bin/supervisord --nodaemon diff --git a/mod/core/prefix-log b/mod/core/prefix-log new file mode 100755 index 0000000..be973e3 --- /dev/null +++ b/mod/core/prefix-log @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# setup fd-3 to point to the original stdout +exec 3>&1 +# setup fd-4 to point to the original stderr +exec 4>&2 + +# get the prefix from SUPERVISOR_PROCESS_NAME environement variable +printf -v PREFIX "%-14.14s" ${SUPERVISOR_PROCESS_NAME} + +# reassign stdout and stderr to a preprocessed and redirected to the original stdout/stderr (3 and 4) we have create eralier +exec 1> >( perl -ne '$| = 1; print "'"${PREFIX}"' | $_"' >&3) +exec 2> >( perl -ne '$| = 1; print "'"${PREFIX}"' | $_"' >&4) + +# from here on everthing that outputs to stdout/stderr will be go through the perl script + +exec "$@" \ No newline at end of file diff --git a/mod/core/supervisord.conf b/mod/core/supervisord.conf new file mode 100644 index 0000000..2a581a5 --- /dev/null +++ b/mod/core/supervisord.conf @@ -0,0 +1,46 @@ +[program:red5] +command=/usr/local/bin/prefix-log /usr/share/red5/red5.sh +user=red5 +directory=/usr/share/red5 +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:bbb-web] +command=/usr/local/bin/prefix-log /usr/share/bbb-web/run-prod.sh +user=bigbluebutton +directory=/usr/share/bbb-web +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:bbb-apps-akka] +command=/usr/local/bin/prefix-log /usr/share/bbb-apps-akka/bin/bbb-apps-akka +user=bigbluebutton +directory=/usr/share/bbb-apps-akka +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:bbb-fsesl-akka] +command=/usr/local/bin/prefix-log /usr/share/bbb-fsesl-akka/bin/bbb-fsesl-akka +user=bigbluebutton +directory=/usr/share/bbb-fsesl-akka +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:bbb-transcode-akka] +command=/usr/local/bin/prefix-log /usr/share/bbb-transcode-akka/bin/bbb-transcode-akka +user=bigbluebutton +directory=/usr/share/bbb-transcode-akka +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +