Supervised Caddy

Caddy, the HTTP/2 web server with automatic HTTPS, is easy to configure and use. The release package contains information about executing Caddy as a service, e.g. with Systemd or Upstart.

This post shows a configuration using Supervisor a process control and monitoring system. Benefits are: reboot safe execution, automatic restart after crashes and execution as a non-root user.

The following steps were tried on Ubuntu 14.04/16.04 and Debian 8.

Prepare Caddy

Prepare Supervisor

[program:caddy]
command=/usr/local/bin/caddy -agree=true -email=<your mail> -conf=/etc/caddy/Caddyfile
environment=CADDYPATH=/etc/caddy/ssl
directory=/var/log/caddy
user=www-data
stdout_logfile=/var/log/caddy/caddy.log
stderr_logfile=/var/log/caddy/caddy.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=600
startretries=3

Manage Caddy execution

Supervised processes can be managed using supervisorctl.

# supervisorctl status
caddy               RUNNING    pid 954, uptime 1 day, 21:16:16

root@mschoebel:~# supervisorctl restart caddy
caddy: stopped
caddy: started

Caddy output (e.g. during startup) is written to /var/log/caddy/caddy.log.