I was reading a post about using Bittorrent Sync on OS X that includes a launchd plist that's supposed to keep the app running in the event that it crashes. It doesn't seem to work, though, since I've had the app crash and not relaunch. I'm looking for help fixing the plist.
The plist looks like this:
<?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>KeepAlive</key> <dict> <key>Crashed</key> <true/> <key>SuccessfulExit</key> <false/> </dict> <key>Label</key> <string>sync.com.tjluoma.bittorrentsync</string> <key>ProgramArguments</key> <array> <string>/usr/bin/open</string> <string>-W</string> <string>-a</string> <string>BitTorrent Sync</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
The "clever" bit is using
/usr/bin/open to launch the app, with
-W to make sure that
open waits for the app to exit. But I think that's also why it doesn't actually work. If I'm reading this right, the app will only relaunch if
/usr/bin/open crashes, not if Bittorrent Sync crashes. For the above approach to work,
open would need to return error status if the app it opened had crashed (and this does not happen).
I know I could fix this by dropping
open and instead hard coding the path to the executable as
/Applications/BitTorrent Sync.app/Contents/MacOS/BitTorrent Sync. But is there an alternative that doesn't require hard-coding the full path? Using
open would be elegant, if it worked.