#!/bin/bash # No systemd in the container, so the services run directly. The DB must be # accepting connections before vectorapi starts, or vectorapi exits - so the # port is waited on rather than slept past. A copied data directory can take # minutes to recover, which is why the wait is generous and reports how long it # took: that number is the cold-boot cost and is worth reading. set -e mkdir -p /var/lib/smartbotic-database chown -R smartbotic-db:smartbotic-db /var/lib/smartbotic-database 2>/dev/null || true su -s /bin/bash smartbotic-db -c '/usr/bin/smartbotic-database --config /etc/smartbotic-database/config.json' 2>&1 | sed 's/^/[db] /' & for i in $(seq 1 600); do (exec 3<>/dev/tcp/127.0.0.1/9004) 2>/dev/null && break sleep 1 done echo "[entrypoint] database accepting connections after ${i}s" sed -i 's/"bind_address": *"[^"]*"/"bind_address": "0.0.0.0"/' /etc/smartbotic-vectorapi/config.json || true /usr/bin/smartbotic-vectorapi --config /etc/smartbotic-vectorapi/config.json 2>&1 | sed 's/^/[api] /' & for i in $(seq 1 120); do (exec 3<>/dev/tcp/127.0.0.1/8080) 2>/dev/null && break sleep 1 done echo "[entrypoint] READY: api up after ${i}s" wait -n