Last active
February 3, 2021 17:15
-
-
Save sebastianmarkow/6b123d89a3f3787c1e3c to your computer and use it in GitHub Desktop.
caddy web server openrc startup script
This file contains hidden or 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
Thanks your share, but my caddy only run by setting user as root. (have setting php-fpm run by "user = caddy, grooup = caddy"),any suggest?