WebApp Restart Challenge


I have a web app that crashes from time to time and I was looking for a way to detect the crash from the Mac terminal and restart the web server. Currently, I have a simple Applescript routine that I can run to kill the process and restart the terminal/web app, but I need a way to detect the crash from the terminal. When a failure occurs, a message will appear in the terminal and I was hoping to simply sense the change in text and initiate the applescript routine.

Can anyone advise as to a way to do this?

Thanks, Sean

Set up a special/api handler. Ping it periodically.

Is this a standalone app running on a Mac?

A Launchd script (quite easy to do something basic)

That’s what I was thinking. I recommend the app LaunchControl to create and manage them, and launchd has an option to relaunch an app if it quit improperly.

But only if this is a standalone app running on a Mac.

Yes, it is a standalone app running on a Mac. Thanks

Naturally, it would be better to identify the cause of the crash and fix it.

if you start the WE app via launchd, launchd will restart the app for you. I would also put in some code to dump the stack on a crash.

I agree with Kem on identifying the root of the crash.


Yes, more than true with regards to finding/fixing the root issues. However, without diving into the details, fixing the issues (not related to the WebApp itself) will be significantly more difficult to resolve I believe. Thanks