Solved How to get caddy file to autostart with Rc.d script

kenden

New Member


Messages: 2

I have a jail with caddy, mysql and wordpress running. I do not know how get the caddy service to autostart.
Caddy runs with the command "caddy run ---config /path/to/Caddyfile"

the Caddy service that I have kluged together runs and works perfectly "service caddy start" but will not auto-run on startup. Any help in making this work, is greatly appreciated.

The rc.conf includes the caddy_enable=YES.


Code:
 /etc/local/etc/rc.d/caddy

#!/bin/sh

. /etc/rc.subr
name="caddy"
rcvar="caddy_enable"
#load_rc_config "$name"

# Set defaults
: ${caddy_enable:="no"}
: ${caddy_config="/usr/local/www/Caddyfile"}
: ${caddy_flags="start" "--config $caddy_config"}
: ${caddy_user="caddy"}
: ${caddy_ender="stop"}

command="/usr/local/bin/${name}"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
sig_reload="USR1"

caddy_start() {
  echo "Starting caddy server."
  ${command} ${caddy_flags}
  echo "All Done Starting!"
}

caddy_stop() {
  echo"all things are ending"
  ${command} ${caddy_ender}
  echo "DONE serving!"
}

load_rc_config $name

run_rc_command "$1"
 
OP
K

kenden

New Member


Messages: 2

Thank you so much! That was the missing link. I have read through "Practical rc.d scripting in BSD" several times and just did not pickup the requirement for at least one keyword to necessary connect to the base system.
 
Top