Skip to content

Instantly share code, notes, and snippets.

@rsobers
Created September 6, 2011 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsobers/1198548 to your computer and use it in GitHub Desktop.
Save rsobers/1198548 to your computer and use it in GitHub Desktop.
Bash script to forcefully kill stray Mod_Mono processes on FogBugz server
#!/bin/sh
# if there is more than one mod-mono-server2, we need to get aggressive
if [ `ps -fu fogbugz | grep mod-mono-server2 | wc -l` -gt 1 ]; then
# try to stop things gracefully
/etc/init.d/fogbugzctl stop
sleep 1
echo "Killing all stray processes owned by fogbugz"
until [ `ps -fu fogbugz | grep fogbugz | wc -l` = 0 ]; do
pkill -u fogbugz
sleep 1
done
until [ `ps -fu fogbugz | grep mod-mono-server2 | wc -l` -gt 0 ]; do
/etc/init.d/fogbugzctl start
sleep 1
done
echo "Stopping heartbeat"
until [ `ps -fu fogbugz | grep heartbeat | wc -l` -lt 1 ]; do
/etc/init.d/fogbugzctl stop-hb
sleep 1
done
echo "Hitting heartbeat with curl using fBreakLock=1"
curl http://localhost:7066/hearbeat.asp\?fBreakLock\=1 > /dev/null
echo "Starting heartbeat"
/etc/init.d/fogbugzctl start-hb
logger -s "Forcefully destroyed Mono."
fi
@rsobers
Copy link
Author

rsobers commented Sep 6, 2011

A couple of critical things:

  1. This requires that curl is installed.
  2. It assumes that the user running FogBugz is called fogbugz.
  3. It assumes you have logger installed.
  4. It assumes that your FogBugz installation can be reached at: http://localhost:7066

Modify the script accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment