kennell/curldrop

[INFO] Quit server on macOS

JayBrown opened this issue · 1 comments

Fantastic program, thank you!

It seems that curldrop doesn't come with an --exit option, but I successfully used the following small script on macOS Big Sur. (In my case I'm running the standard python3 program installed with Xcode, which is why I need to grep for the path to the Python app bundle.)

#!/bin/zsh
while read -r pid
do
	if ! kill -n 3 "$pid" 2>/dev/null ; then
		if ! kill -n 9 "$pid" 2>/dev/null ; then
			echo "Error killing PID $pid" >&2
			continue
		else
			echo "Successfully killed PID $pid (9)"	
		fi
	else
		echo "Successfully killed PID $pid (3)"	
	fi
done < <(ps aux | grep "/Python.app/Contents/MacOS/Python " | grep "/curldrop " | awk '{print $2}' | sort -nr)

While working on the companion app I have found that launchd would be the correct solution; the above snippet or something similar can still be used to check for orphan workers, but using a LaunchAgent and launchctl load | unload and launchctl start | stop is a surefire solution on macOS.