File: //etc.defaults/init/pkg-ProxyServer.conf
cgroup cpuacct "pkgctl-ProxyServer"
cgroup memory "pkgctl-ProxyServer"
description "start squid for ProxyServer"
author "Network Infrastructure Team"
console log
respawn
respawn limit 5 10
expect fork
pre-start script
echo "Starting squid..."
end script
post-stop script
function get_childs_pid() {
echo "`/usr/bin/ps -ef | /usr/bin/grep -v grep | /usr/bin/grep '(squid-[0-9]*)' | /usr/bin/awk '{print $2}'`"
}
echo "Stopping squid..."
WAIT_RETRY="10"
while [ 1 ]; do
CHILDS_PID="`get_childs_pid`"
if [ "0" -ge "$WAIT_RETRY" ]; then
echo "squid child process (PID $CHILDS_PID) still running, force shutdown them..."
echo "$CHILDS_PID" | /usr/bin/xargs -n 1 /usr/bin/kill -9 || true
break
fi
WAIT_RETRY=$(($WAIT_RETRY - 1))
[ -z "$CHILDS_PID" ] && break
for each_pid in "$CHILDS_PID"; do
if [ -d "/proc/$each_pid" ]; then
/usr/bin/sleep 1
continue 2 # continue while loop
fi
done
break
done
end script
exec /var/packages/ProxyServer/target/bin/squid
# vim:ft=upstart