From 56fbf8ae0c08cde14b686c3b6029341219aef90b Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 27 Nov 2020 19:31:33 +0000 Subject: [PATCH] docker fixes for salt modules and nats config reload --- docker/containers/tactical-nats/entrypoint.sh | 7 +++++-- docker/containers/tactical-salt/dockerfile | 1 + docker/containers/tactical-salt/entrypoint.sh | 21 ++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docker/containers/tactical-nats/entrypoint.sh b/docker/containers/tactical-nats/entrypoint.sh index fd7b2158..3272a67d 100644 --- a/docker/containers/tactical-nats/entrypoint.sh +++ b/docker/containers/tactical-nats/entrypoint.sh @@ -11,6 +11,9 @@ done mkdir -p /var/log/supervisor mkdir -p /etc/supervisor/conf.d +# wait for config changes + + supervisor_config="$(cat << EOF [supervisord] nodaemon=true @@ -18,13 +21,13 @@ nodaemon=true files = /etc/supervisor/conf.d/*.conf [program:nats-server] -command=nats-server -DVV --config "${TACTICAL_DIR}/api/nats-rmm.conf" +command=nats-server --config ${TACTICAL_DIR}/api/nats-rmm.conf stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 redirect_stderr=true [program:config-watcher] -command="inotifywait -m -e close_write ${TACTICAL_DIR}/api/nats-rmm.conf"; | while read events; do "nats-server --signal reload"; done; +command=/bin/bash -c "inotifywait -mq -e modify "${TACTICAL_DIR}/api/nats-rmm.conf" | while read event; do nats-server --signal reload; done;" stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 redirect_stderr=true diff --git a/docker/containers/tactical-salt/dockerfile b/docker/containers/tactical-salt/dockerfile index b6f446cd..21c90ec2 100644 --- a/docker/containers/tactical-salt/dockerfile +++ b/docker/containers/tactical-salt/dockerfile @@ -1,6 +1,7 @@ FROM ubuntu:20.04 ENV TACTICAL_DIR /opt/tactical +ENV TACTICAL_READY_FILE ${TACTICAL_DIR}/tmp/tactical.ready ENV SALT_USER saltapi RUN apt-get update && \ diff --git a/docker/containers/tactical-salt/entrypoint.sh b/docker/containers/tactical-salt/entrypoint.sh index ff82c8af..253be7af 100644 --- a/docker/containers/tactical-salt/entrypoint.sh +++ b/docker/containers/tactical-salt/entrypoint.sh @@ -4,10 +4,10 @@ set -e : "${SALT_USER:='saltapi'}" -# wait for salt password to be generated by tactical-init -until [ -f "${TACTICAL_DIR}/tmp/salt_pass" ]; do - echo "waiting for salt password to be generated..." - sleep 10 +sleep 15 +until [ -f "${TACTICAL_READY_FILE}" ]; do + echo "waiting for init container to finish install or update..." + sleep 10 done SALT_PASS=$(cat ${TACTICAL_DIR}/tmp/salt_pass) @@ -15,7 +15,10 @@ SALT_PASS=$(cat ${TACTICAL_DIR}/tmp/salt_pass) echo "${SALT_USER}:${SALT_PASS}" | chpasswd cherrypy_config="$(cat << EOF -module_dirs: ['/opt/tactical/_modules'] +file_roots: + base: + - /srv/salt + - ${TACTICAL_DIR} timeout: 20 gather_job_timeout: 25 max_event_size: 30485760 @@ -42,11 +45,15 @@ nodaemon=true files = /etc/supervisor/conf.d/*.conf [program:salt-master] -command=/bin/bash -c "salt-master -l debug" +command=/bin/bash -c "salt-master -l info" +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 redirect_stderr=true [program:salt-api] -command=/bin/bash -c "salt-api -l debug" +command=/bin/bash -c "salt-api -l info" +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 redirect_stderr=true EOF )"