Can a CGI app check its HTTP status?

Can a running CGI app check its own HTTP status? I’d like to be able to have it kill itself if it sees it’s returning Error 500. If I can do that, then I can set AutoQuit=False and not worry about having to kill it when it’s returning Error 500. Right now, I have it killed when sessions drop to 0, which always gets rid of the occasional Error 500 without my intervention. This occasional error only seems to arise when hitting a non-running CGI app, so AutoQuit=False might get rid of this. I just want make to sure that rare case where a running CGI app returns that error (which I have yet to see) is handled without my intervention.

these error 500 with CGIs are a real showstopper. finally I gave up on this issue and better restart the whole webserver twice a day via cron job. This worked for me well cause nothing else is running on the server. You could write a daemon, trying to detect error 500 and then triggering restart on demand but in the end the cron job did the job.

CGIs are decprecated, xojo is moving on to standalone webservers behind reverse proxies. A good move from this perspective.

If you don’t care to have the CGI app running 24/7, you can just have an App timer kill it when it sees SessionCount=0. I find this terminates all Error 500s when they happen, without any other intervention. I found the framework’s AutoQuit didn’t always kill the app when SessionCount=0 when there was an Error 500 present, but the App timer does. Of course this assumes your app reliably gets to SessionCount=0.

I was just hoping to find a way to have the app running 24/7 and still get rid of the rare Error 500. So far, I have only seen Error 500 occur when a user hits the app when it’s not running, but am not sure it can’t happen otherwise.

Would an App.Timer that runs the following method kill the app if it’s returning an Error 500:

Dim r As New WebRequest If r.Status = 500 Then Self.Quit

I’m just not sure what that WebRequest is targeting. Is it targeting the currently running app’s URL?

Do you know the cause of the 500 error? Is it your app or the host server?

Usually the host is responsible for controlling a CGI app and doubt that it will take kindly to an app going away…

[quote=439291:@Ralph Alvy]Would an App.Timer that runs the following method kill the app if it’s returning an Error 500:

Dim r As New WebRequest If r.Status = 500 Then Self.Quit

I’m just not sure what that WebRequest is targeting. Is it targeting the currently running app’s URL?[/quote]
As I said in the other thread, no. WebRequests are objects you get from the framework, not ones you should be creating yourself.

Yes. I understand that now, reading your other post. Sorry for what is essentially a double post.

In Linux environment, you can use crontab and wget return values to write scripts to kill processes.