#!/bin/sh
exec 2>&1

# Add $ARGS for more arguments to node_exporter
[ -f ./conf ] && . ./conf

: ${RUNIT_COLLECTOR:='--collector.runit --collector.runit.servicedir /var/service'}
[ -n "${LISTEN_ADDR}" ] && LISTEN_ADDR="--web.listen-address ${LISTEN_ADDR}"

# Not by default since the runit collector needs root, no magic group for runit access.
[ -n "${USE_LOCAL_USER}" ] && : ${USER:=_node_exporter}
[ -n "${USER}" ] && CHPST_USER="-u ${USER}"

exec chpst $CHPST_USER node_exporter ${RUNIT_COLLECTOR} ${LISTEN_ADDR} ${ARGS} 2>&1
