Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created February 9, 2015 05:28
Show Gist options
  • Save tjluoma/62e7fb663e9c9da207b5 to your computer and use it in GitHub Desktop.
Save tjluoma/62e7fb663e9c9da207b5 to your computer and use it in GitHub Desktop.
launchd plist to launch BitTorrent Sync and keep it running, even if it crashes
<?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>
@atomicbird
Copy link

This doesn't work as intended, because it relies on /usr/bin/open to launch BitTorrent Sync. Because of that, launchd will only re-launch the app if /usr/bin/open returns error status when the app crashes. But it returns 0 in that case, so on an app crash, launchd still sees a successful exit. A working version would have to launch BitTorrent Sync directly so as to pick up its crash status. I uploaded one version of this at https://gist.github.com/atomicbird/ff2de46a594cdb5c8e69

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