HansaWorld Enterprise is probably the most used enterprise-level business software for the Mac in Europe (maybe because it's the only one). It's been around for ages and so has picked up a bit of cruft along the way (I hear there's a native Cocoa port in the works, but we'll see). This means that when it works, it works, but when it starts to crash, you're options are to try what little tricks you may know yourself, pay an insane amount of money to have some guy look at it, or just restart it.
You can easily automate the latter with combining launchd and a bit of shell:
#!/usr/bin/env bash # /Library/Scripts/hansakicker.sh if ps -Ac | grep -q hansa51 ; then logger "Hansa is running, no need to restart" sleep 10 else sleep 10 logger "Hansa crashed, restarting" launchctl start my.hansa.launchd fi exit 0
A couple of obvious things to note: in this case the Hansa binary is called “hansa51”, it may differ in your install. The sleep commands are there to calm launchd down. The second sleep comes before everything else to give CrashReporter time to finish up. Also this assumes that Hansa's being started from launchd, ie with something like:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>fi.humac.hansa5</string> <key>ProgramArguments</key> <array> <string>/Applications/Hansa5/hansa51</string> </array> <key>RunAtLoad</key> <true/> <key>WorkingDirectory</key> <string>/Applications/Hansa5</string> </dict> </plist>
In the launchd part, we are simply looking for the moment Hansa's crash log is modified:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.$ <plist version="1.0"> <dict> <key>Label</key> <string>my.hansa.hansakicker</string> <key>OnDemand</key> <true/> <key>ProgramArguments</key> <array> <string>/Library/Scripts/hansakicker.sh</string> </array> <key>WatchPaths</key> <array> <string>/Library/Logs/CrashReporter/hansa51.crash.log</string> </array> </dict> </plist>
Once everything's been set up and loaded in, we can do a test:
… which should trigger the script.
Obviously this is little more than a band-aid and you should really do something about it if this happens daily, but is more than useful for those intermittent Saturdays when you're salesforce is working and you're not. :-)