Skip to content

Commit

Permalink
Don't wait 30 seconds to stop the daemon.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam committed Aug 6, 2013
1 parent ad78df2 commit 71b7991
Showing 1 changed file with 8 additions and 38 deletions.
46 changes: 8 additions & 38 deletions www/squid/files/squid.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: squid.sh,v 1.21 2008/03/11 15:46:41 taca Exp $
# $NetBSD: squid.sh,v 1.22 2013/08/06 15:44:34 adam Exp $
#

# PROVIDE: squid
# REQUIRE: DAEMON
# KEYWORD: shutdown
Expand All @@ -20,54 +19,25 @@ pidfile="@VARBASE@/run/${name}.pid"
required_files="${squid_conf} @PKG_SYSCONFDIR@/mime.conf"
command_args="-Y -f ${squid_conf}"

stop_cmd="stop_nicely"
kill_command="${command} ${squid_flags} ${command_args} -k shutdown"
# Note: 'shutdown' waits 30 seconds, while 'interrupt' stops immediately
stop_cmd="${command} ${squid_flags} ${command_args} -k interrupt"
reload_cmd="${command} ${squid_flags} ${command_args} -k reconfigure"
rotate_cmd="${command} ${squid_flags} ${command_args} -k rotate"
createdirs_cmd="${command} ${squid_flags} ${command_args} -z"
extra_commands="createdirs reload rotate"

#### end of configuration section ####

# XXX Shouldn't the default stop_cmd be this patient too?
#
stop_nicely ()
{
if [ -f ${pidfile} ] ; then
DAEMON_PID=`sed 1q ${pidfile}`
@ECHO@ -n "Stopping ${name}"
${kill_command}
if [ ${DAEMON_PID} -ne 0 ]; then
@ECHO@ -n '['
for WAIT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
if kill -0 ${DAEMON_PID} >/dev/null 2>&1; then
sleep 4
@ECHO@ -n '.'
test $WAIT -lt 15 || kill ${DAEMON_PID}
else
break
fi
done
@ECHO@ '].'
unset WAIT
fi
unset DAEMON_PID
fi
}

if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]; then
load_rc_config $name
run_rc_command "$1"
else # old NetBSD, Solaris, Linux, etc...
else
if [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi
case $1 in
start)
start_cmd="${command} ${squid_flags} ${command_args}"
if [ -x ${command} -a -f ${squid_conf} ] ; then
eval ${start_cmd} && @ECHO@ -n " ${name}"
${start_cmd}
fi
;;
stop)
Expand All @@ -77,17 +47,17 @@ else # old NetBSD, Solaris, Linux, etc...
${createdirs_cmd}
;;
reload)
if [ -f ${pidfile} ] ; then
if [ -r "${pidfile}" ] ; then
${reload_cmd}
fi
;;
rotate)
if [ -f ${pidfile} ] ; then
if [ -r "${pidfile}" ] ; then
${rotate_cmd}
fi
;;
*)
@ECHO@ "Usage: $0 {start|stop|reload|createdirs}" 1>&2
@ECHO@ "Usage: $0 {start|stop|reload|rotate|createdirs}" 1>&2
exit 64
;;
esac
Expand Down

0 comments on commit 71b7991

Please sign in to comment.