about summary refs log tree commit diff
path: root/bundles/svtree-www/files/etc/s6-rc/templates/www/+service-srv/run
blob: 677d7e1ee3557bc1e0104a9a2d40e8560c29a418 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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}