Max Crash Demon

Here’s a little application I wrote for a permanent installation.
This python script will run a ps command every minute to check if max is still running. If max isn’t running, the script will restart max.

go to /Applications/Utilities/Console.app to see what maxcrashdemon sez.

if you got apple’s developer tools installed, i recommend using the following python script. it allows you to choose which file to launch in case max crashes and can even send out emails to alert someone.

just copy the code into a textfile “maxcrashdemon.py”. once you finished editing the code, double-click this file and BuildApplet.app will create an application, which you can then add to your login-items on the machine running the installation:

############# Robin Meier Paris Octobre 2007 for soham sound #############
 
import commands #to use terminal commands
import smtplib #to send mails
import time #to sleep
 
i = 1 #forever
 
def alert(server):
	smtplib.SMTP(server).sendmail('edit_from@address.fr', 'edit_to@address.fr',
	"""yo, max crashed!!!! but don't worry... i just restarted max....
	""")
	smtplib.SMTP(server).quit()
 
comm = 'ps -x | grep MaxMSP | grep -v grep' #instead of MaxMSP you could put any other application
 
while i == 1:
	stillup = commands.getoutput(comm)
	if stillup == '' :
		print "ouch, send a mail and open max (or patch) again"
		commands.getoutput('open /Applications/MaxMSP\ 4.6/MaxMSP.app') #put the path to your patch here instead
		alert('smtp.truc.fr') #you have to put a working SMTP server here
	else:
		print "everything fine"
		time.sleep(60) #check every 60 seconds - i wouldn't do this too often - go easy on your cpu...
		continue