Auto Restart Precessing Apps
in
Library and Tool Development
•
1 year ago
Hello
I was just gathering some code snippets for a script that will watch if a certain application is running and will automatically restart it in case of a crash or if the user is quitting it.
This might me useful if you show a processing app in an exhibition.
Of course there should be no bugs and it shouldn't crash, but you never know for sure ;-)
All you need is a launcher.plist...
-
<dict>
-
<string>com.restart.launcher</string> -
<key>Program</key>
-
<string>
/Applications/Opera.app/Contents/MacOS/Opera</string> -
<key>KeepAlive</key>
-
<true/>
-
<key>RunAtLoad</key>
-
<false/>
-
</dict/>
and a terminal command to start it.
-
launchctl load "${0%/*}/com.restart.launcher.plist"
This works well. There is only one problem.
The file of the application to be watched is in the package contents: Contents > MacOS
Processing Applications don't have that file in the package content or rather an file called "JavaApplicationStub".
Unfortunately it doesn't work with this file.
Any suggestions?
I know that there is a App called
Lingon that may do the job but my script also does a bunch of other stuff that Lingon won't.