#!/bin/execlineb -P # load location of deployments from system config envfile /etc/s6-rc/system.conf importas -iu www_dir www_dir # load port from service config envfile /etc/s6-rc/+service.conf importas -iu www_port www_port # route all logs to stdout fdmove -c 2 1 ifthenelse -s { eltest -e ${www_dir}/+service/Caddyfile } { define caddyfile ${www_dir}/+service/Caddyfile } { define caddyfile /etc/caddy/www.conf } # check that port env var is actually used if -X { grep -q CADDY_HTTP_PORT ${caddyfile} } export CADDY_HTTP_PORT ${www_port} cd ${www_dir}/+service exec caddy run --watch \ --pidfile=/dev/fd/3 \ --adapter=caddyfile \ --config=${caddyfile}