From a808252079a5c6800d6d7ff665a071f3402261c4 Mon Sep 17 00:00:00 2001 From: Tim Lewis Date: Mon, 18 Sep 2017 17:31:36 -0400 Subject: [PATCH 1/2] Fix spurious .pid file error in linux-sysvinit This change eliminates the `[ERROR] Could not write pidfile: open /var/run/caddy.pid: permission denied` from caddy.log. The start-stop-daemon writes the file as root so the DAEMONUSER that caddy runs as cannot write to the .pid file. --- dist/init/linux-sysvinit/caddy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/init/linux-sysvinit/caddy b/dist/init/linux-sysvinit/caddy index 763f3fa6..3b5d0b12 100644 --- a/dist/init/linux-sysvinit/caddy +++ b/dist/init/linux-sysvinit/caddy @@ -20,7 +20,7 @@ DAEMONUSER=www-data PIDFILE=/var/run/$NAME.pid LOGFILE=/var/log/$NAME.log CONFIGFILE=/etc/caddy/Caddyfile -DAEMONOPTS="-agree=true -pidfile=$PIDFILE -log=$LOGFILE -conf=$CONFIGFILE" +DAEMONOPTS="-agree=true -log=$LOGFILE -conf=$CONFIGFILE" USERBIND="setcap cap_net_bind_service=+ep" STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" From fea8f37f9d649207612cf94033c7672d751a46b0 Mon Sep 17 00:00:00 2001 From: Tim Lewis Date: Mon, 18 Sep 2017 17:48:28 -0400 Subject: [PATCH 2/2] Fix linux-sysvinit script to prevent missing caddy.log Create /var/log/caddy.log and chown prior to starting caddy. Caddy running as DAEMONUSER does not have permission to create the /var/log/caddy.log. --- dist/init/linux-sysvinit/caddy | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/init/linux-sysvinit/caddy b/dist/init/linux-sysvinit/caddy index 3b5d0b12..88fc9639 100644 --- a/dist/init/linux-sysvinit/caddy +++ b/dist/init/linux-sysvinit/caddy @@ -36,6 +36,7 @@ ulimit -n 8192 start() { $USERBIND $DAEMON + touch $LOGFILE && chown $DAEMONUSER $LOGFILE start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE \ --background --chuid $DAEMONUSER --oknodo --exec $DAEMON -- $DAEMONOPTS }