No more server downtime

Jan 3, 2013

I’d noticed that my blog would randomly become inaccessible as the node.js server I have running would (presumably) throw an error and crash. My current setup involves one instance of Apache to run Wordpress on and a bunch of other instances of node.js that run on different ports, and one central node.js router instance that listens on port 80 and then routes connections to different ports depending on the subdomain in the HTTP request. Being lazy, I haven’t implemented any true error-handling in the router instance and neither am I echo-ing its output to a logfile, so I was clueless as to why it kept crashing.

Looking around for an npm module that would automatically restart my node.js instances, I discovered Forever, and it was a breeze to set up. The service not only automatically restarts all specified instances and logs their output, but it also prints a list of all PIDs a given instance has taken till date (as in, x when you first launched, y when Forever resurrected it after the first crash, z when it was resurrected after the second crash, and so on).

So, long story short, my blog should stay up forever.

On an unrelated note, I got a Galaxy S3, and it’s an awesome phone. No pics (of the phone) incoming though, because I’m not inclined to take a self-shot of the phone in a mirror.