Help With Caddy Startup Script

warllo

Contributor
Joined
Nov 22, 2012
Messages
117
I'm trying to get Caddy V2 running in a jail. I've install Caddy as described in this link https://www.jaredwolff.com/how-to-compile-caddy-on-freebsd/ but I'm having trouble getting caddy to run as a service. I've used the startup script below.

Code:
# $FreeBSD: head/net/caddy/files/caddy.in 452063 2017-10-14 12:58:24Z riggs $
#
# PROVIDE: caddy
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# caddy_enable (bool):    Set to NO by default.
#                Set it to YES to enable caddy.
# caddy_user (user):        Set user to run caddy.
#                Default is "caddy".
# caddy_group (group):    Set group to run caddy.
#                Default is "caddy".
# caddy_conf (path):        Path to caddy configuration file.
#                Default is /usr/local/etc/caddyfile.conf

. /etc/rc.subr

name=caddy
rcvar=caddy_enable

load_rc_config $name

: ${caddy_enable:="NO"}
: ${caddy_user:="caddy"}
: ${caddy_group:="caddy"}
: ${caddy_conf:="/usr/local/etc/caddyfile.conf"}
: ${caddy_log:="/home/caddy/caddy.log"}
: ${caddy_env:="CADDYPATH=/home/caddy/"}
: ${caddy_https_port:="4443"}
: ${caddy_http_port:="8880"}

pidfile=/var/run/caddy.pid
procname="/usr/local/bin/caddy"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} /usr/bin/env ${caddy_env} ${procname} -agree -http-port ${caddy_http_port}  -https-port ${caddy_https_port} -conf=${caddy_conf} -log=${caddy_log} ${caddy_args}"

start_precmd=caddy_startprecmd

caddy_startprecmd()
{
        if [ ! -e ${pidfile} ]; then
                install -o ${caddy_user} -g ${caddy_group} /dev/null ${pidfile};
        fi
}

run_rc_command "$1"


It will say that Caddy is starting but it's not running and the log files are not in the expected location. Hoping for some help.
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Is there a reason your trying to install it manually. You can install caddy with pkg install caddy and it does everything for you, including the rc script.
 
Joined
Jan 4, 2014
Messages
1,644
You can install caddy with pkg install caddy and it does everything for you, including the rc script.
That will install Caddy 1.0.4. The OP requires V2.
 

warllo

Contributor
Joined
Nov 22, 2012
Messages
117
I was able to patch something together that mostly works. Looks like there is a Caddy V2 port in the works but it's not ready yet.
 
Top