Solving the Internal Server Error 500 problem

I find Xojo CGI apps very vulnerable to returning a status 500 (user gets an Internal Server Error 500) when they’re asleep and hit by a mobile browser. I never see this happen when hitting a woke Xojo CGI app. So I’ve handled this by setting App.AutoQuit=False, starting the app and letting it run. I haven’t seen a status 500 since doing this.

However, since it’s still theoretically possible to get a status 500 when hitting a woke Web CGI app (though I’ve not seen that in my logs), I have a helper CGI app poll the main CGI app for status 500 hourly, and restart it if found. For the helper CGI app to be able to restart the main CGI app, it takes advantage of a special timer in the main CGI app (http://www.dev.1701software.com/blog/2013/09/08/upgrading-xojo-cgi-apps).

Thanks for posting the blog URL. Since 1701 became ServerWarp, I could not locate it.

BTW I do get the 500 error now and then, when one of my cgi apps becomes unresponsive. I then reboot the server and it takes care of it.

I cannot move out easily, because I have at least a half dozen domains and all the fonts and programs for instant download.

Besides Xojo Cloud which would not support all my domains anyway, any suggestions of alternatives ?

Assuming you have the App timer running (that kills the app if the CGI file is absent), why don’t you don’t just rename the CGI file, and then rename it back? And if that works, why not just have the App timer also kill the app if no sessions are present?

I see that Paul Budd found he also had to make sure CGI apps run with App.AutoQuit=False to keep them from being unresponsive (in his XDC 2019 video on Web app development). I wish I had thought of this a long time ago.

This shell-script works for me:

#!/bin/bash

# Get header and safe it in /tmp/foo
# /tmp/foo must exist
# Replace yoururl.com and yourApp.cgi
curl --head "https://yoururl.com/yourApp.cgi" > /tmp/foo

# Check status and save it in variable MSTAT
# 1: HTTP-Status = 500 >> kill process
# 0: HTTP-Status <> 500 
MSTAT="`wget -q  -O /tmp/foo https://yoururl.com/yourApp.cgi | grep '500' /tmp/foo | wc -l`"

# If status = 500: kill process
if [[ $MSTAT -eq "1" ]] 
then
   killall yourApp
fi