Skip to content

Instantly share code, notes, and snippets.

@necrose99
Forked from sebastianmarkow/caddy
Created May 4, 2018 03:04
Show Gist options
  • Save necrose99/8fffb45f75836052f3ee088819152e2e to your computer and use it in GitHub Desktop.
Save necrose99/8fffb45f75836052f3ee088819152e2e to your computer and use it in GitHub Desktop.
caddy web server openrc startup script
#!/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