0

ASP.NET MVC4 application is running in Debian x64 Linux using Apache and mod_mono

Sometimes site starts to return Duplicate session key errors with http code 5xx and application stops working or it start to return returns request timed out errors.

Only re-starting Apache server fixes this.

How to re-start Apache if site stops working?

I tried to create crontab job which checks site after every 20 minutes using wget according to How to avoid apache to stop responding in MVC application :

wget --timeout=10 --no-verbose --tries=1 -a /var/log/wget.log -O /var/log/wgettulem.html  www.mysite.com || /etc/init.d/apache2 restart

However wget returns zero exit code even if page returns 500 error. So this is not working. If site returns 500 http error code, Apache is not restarted.

How to restart Apache automatically if page returns 5xx or 4xx http error code?

Community
  • 1
  • 1
Andrus
  • 26,339
  • 60
  • 204
  • 378
  • `$ wget -qO - 'http://foo/return500' ; echo $?` returns `8` for me. Which according to `man wget` is “Server issued an error response”. – lxg Sep 14 '14 at 19:43
  • It it is so then why line in question does not restart apache if 500 error code is returned in page? – Andrus Sep 14 '14 at 20:06
  • Most likely because the page you're retrieving doesn't return a HTTP 500 at all. I'd suggest setting up a test scenario with a page that *always* causes a HTTP 500, and see if you can restart Apache when checking that page. – lxg Sep 14 '14 at 20:42
  • This error seems to occur if ASP.NET session cookie is present. wget does not send it so it receives normal response. How to add session cookie to request? ASP.NET assigns it automatically in first login. – Andrus Sep 15 '14 at 08:57
  • I don't know, maybe you should ask a new SO question for that. – lxg Sep 15 '14 at 09:20

0 Answers0