jeudi 26 février 2015

Is this launchd plist broken or is it just me?


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://ift.tt/vvUEPL">
<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 http://ift.tt/1BCl19t Sync. But is there an alternative that doesn't require hard-coding the full path? Using open would be elegant, if it worked.





Aucun commentaire:

Enregistrer un commentaire