#!/usr/bin/env /lib/runit/invoke-run
#Copyright: 2019 Cloux <cloux@rote.ch>
#             2023  Lorenzo Puliti <plorenzo@disroot.org>
#License: CC0-1.0

exec 2>&1

if ! /usr/sbin/nginx -t -q -c /etc/nginx/nginx.conf -g 'daemon off;' ; then
    echo "${PWD##*/}: config test failed"
    sv d "${PWD##*/}"
fi

if [ -e /etc/runit/verbose ]; then
	echo "invoke-run: starting ${PWD##*/}"
fi
# nginx only provides a config file option to run in the foreground:
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g 'daemon off;'
