tacticalrmm/docker/containers/tactical-nats/entrypoint.sh

34 lines
814 B
Bash
Raw Normal View History

2020-11-23 05:15:00 +00:00
#!/usr/bin/env sh
2020-11-22 17:03:40 +00:00
set -e
2020-11-23 05:15:00 +00:00
# wait until nats config file is available
until [ -f "${TACTICAL_DIR}/api/nats-rmm.conf" ]; do
echo "waiting for nats config to be generated..."
sleep 10
done
mkdir -p /var/log/supervisor
mkdir -p /etc/supervisor/conf.d
2020-11-22 17:03:40 +00:00
supervisor_config="$(cat << EOF
[supervisord]
nodaemon=true
[include]
files = /etc/supervisor/conf.d/*.conf
[program:nats-server]
command=nats-server --config ${TACTICAL_DIR}/api/nats-rmm.conf
redirect_stderr=true
2020-11-23 05:15:00 +00:00
[program:config-watcher]
command=inotifywait -q -m -e close_write ${TACTICAL_DIR}/api/nats-rmm.conf | while read events; do nats-server --signal reload; done;
2020-11-22 17:03:40 +00:00
redirect_stderr=true
EOF
)"
echo "${supervisor_config}" > /etc/supervisor/conf.d/supervisor.conf
2020-11-23 05:15:00 +00:00
# run supervised processes
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisor.conf