#!/usr/bin/with-contenv bash

echo "waiting for scrutiny service to start"
s6-svwait -u /var/run/s6/services/scrutiny

#tell s6 to only run this script once
s6-svc -O /var/run/s6/services/collector-once

# wait until scrutiny is "Ready"
until $(curl --output /dev/null --silent --head --fail http://localhost:8080/api/health); do echo "scrutiny api not ready" && sleep 5; done

echo "starting scrutiny collector"
/scrutiny/bin/scrutiny-collector-metrics run
