-
-
Save mkfsn/db0e961edeb71da8b0b59e37b4d983a8 to your computer and use it in GitHub Desktop.
caddy web server openrc startup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/openrc-run | |
description="Caddy web server" | |
description_reload="Reload configuration" | |
extra_started_commands="reload" | |
: ${CADDY_CONF:=/etc/caddy/Caddyfile} | |
: ${CADDY_PIDFILE:=/var/run/caddy.pid} | |
: ${CADDY_USER:=caddy} | |
depend() { | |
need net | |
need localmount | |
use dns | |
after firewall | |
provide webserver | |
} | |
start() { | |
ebegin "Starting caddy" | |
start-stop-daemon --wait 1000 --background --start --exec \ | |
/usr/bin/caddy \ | |
--user ${CADDY_USER} \ | |
--make-pidfile --pidfile ${CADDY_PIDFILE} \ | |
-- -conf "${CADDY_CONF}" -pidfile "${CADDY_PIDFILE}" -agree -quiet && \ | |
chown ${CADDY_USER}:root ${CADDY_PIDFILE} | |
eend $? | |
} | |
stop() { | |
ebegin "Stopping caddy" | |
start-stop-daemon --wait 5000 --stop --exec \ | |
/usr/bin/caddy \ | |
--user ${CADDY_USER} \ | |
--pidfile ${CADDY_PIDFILE} \ | |
-s SIGQUIT | |
eend $? | |
} | |
reload() { | |
ebegin "Reloading caddy configuration" | |
start-stop-daemon --exec \ | |
/usr/bin/caddy \ | |
--user ${CADDY_USER} \ | |
--pidfile ${CADDY_PIDFILE} \ | |
-s SIGUSR1 && \ | |
chown ${CADDY_USER}:root ${CADDY_PIDFILE} | |
eend $? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment