0

I've found a faulty connection to my database caused my development WAMP server to crash, even though the software is in working order, but PHP crashed and took the server down. Is there any way to make WAMP server or Apache itself automatically restart on crash?

Is there any reason I wouldn't want to do this? It's an issue I've had a couple times and I figure even if it crashes and restarts it's better than not being up at all, but I may not be seeing the big picture.

1 Answer 1

3

You can write a watchdog that tries to access a page on your web server and if it fails restarts the server. Run it as a scheduled task every {minute, 5 minutes, half hour, whatever...}. Implementation of this script is left as an exercise for the reader (especially on Windows, but PowerShell is probably going to be your friend).


You are however missing the Big Picture as you suspect - A failed database connection should cause your site to throw errors, but it SHOULD NOT be knocking the web server down. If this were production I would say roll out the watchdog until you can debug the problem, but since this is your development environment I would spend a day or two figuring out why a faulty DB connection is knocking the whole show down.
Bear in mind that if it's happening in development it may happen in production one day, and your employer will likely be less tolerant of the entire production environment shutting down than the developers are of the dev environment occasionally blowing up...

3
  • Unfortunately it looks like my PHP cacher crashed it, but the production database is much more reliable than the dev one; it's an IT server everyone and their brother uses for whatever. Thanks for the Powershell Watchdog tip, I think I'll have to look into why my cache is crashing it first though
    – Ben Brocka
    Sep 13, 2011 at 14:58
  • Solving the crashing problem is the Right Fix - the watchdog is a Quick Fix. If you're using the same cache engine on the production site it's definitely important: One day you will do database maintenance, and the DB will be unavailable for a few seconds. When the DB comes back the web site will be down because it crashed and your pager will be going off :)
    – voretaq7
    Sep 13, 2011 at 15:03
  • The DB has been unavailable before though (it's fairly common on dev), so the problem is less clear unfortunately. I got about 15 page loads in with no DB connection before it actually crashed; thought it was a network error at first.
    – Ben Brocka
    Sep 13, 2011 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .