HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: //etc/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