Lines 61-67
required_files="${caddy_config} ${caddy_command}"
Link Here
|
61 |
|
61 |
|
62 |
start_precmd="caddy_precmd" |
62 |
start_precmd="caddy_precmd" |
63 |
start_cmd="caddy_start" |
63 |
start_cmd="caddy_start" |
64 |
stop_precmd="caddy_prestop" |
64 |
stop_cmd="caddy_stop" |
65 |
|
65 |
|
66 |
# Extra Commands |
66 |
# Extra Commands |
67 |
extra_commands="configtest reload" |
67 |
extra_commands="configtest reload" |
Lines 103-127
caddy_start()
Link Here
|
103 |
fi |
103 |
fi |
104 |
} |
104 |
} |
105 |
|
105 |
|
106 |
caddy_prestop() |
106 |
caddy_stop() |
107 |
{ |
107 |
{ |
108 |
local result |
108 |
if [ -e ${pidfile} ]; then |
|
|
109 |
_PID=$(pgrep -F ${pidfile}) |
110 |
echo -n "Stopping caddy... " |
109 |
|
111 |
|
110 |
echo -n "Stopping caddy... " |
112 |
timeout -k 5s 2s /usr/bin/su -m "${caddy_user}" -c "${caddy_command} stop 2>&1" >/dev/null |
111 |
|
113 |
kill $sig_stop ${_PID} |
112 |
result="$(caddy_execute stop 2>&1)" |
114 |
wait_for_pids ${_PID} |
113 |
if [ ${?} -eq 0 ]; then |
|
|
114 |
echo "done" |
115 |
exit 0 |
116 |
else |
115 |
else |
117 |
if echo "${result}" | grep -q "connection refused"; then |
116 |
echo "${name} is not running." |
118 |
echo "admin interface unavailable; using pidfile" |
117 |
return 1 |
119 |
return 0 |
|
|
120 |
else |
121 |
echo "Error: Unable to stop caddy" |
122 |
echo "Check the caddy log: ${caddy_logfile}" |
123 |
return 1 |
124 |
fi |
125 |
fi |
118 |
fi |
126 |
} |
119 |
} |
127 |
|
120 |
|