In case your Ghost blog goes down
2 min read

In case your Ghost blog goes down

From time to time my two Ghost blogs go down. In most of the cases it happens because my server runs out of memory, it being the smallest VPS DigitalOcean has to offer. Although 512 Mb of RAM are enough for two ghost instances and a couple of static content, it does hiccup from time to time.

The custom Nginx error pages that I made recently are helpful. Even though I would have been happy with only the theory, I was able to confirm they also work as intended in practice.

When Ghost goes down, Nginx automatically shows a 500 error page. My custom error page offered a google cache links that worked flawlessly but it was not a solution, just a way to make the problem less stressful.

The solution itself is often a crude but effective server reboot but in order to apply it, you have to be aware your site is down. Last time this blog went down for way too much time since I do not post nor check it very often. Fortunately, New Relic has uptime monitoring on its free tier.

I have to admit, using New Relic just for uptime monitoring is very overkill, but it's free, simple to set up and works perfectly.

There's a great article about setting up New Relic with Ghost that covers all you need to know.

To sum up, after accessing your Ghost folder, i.e. cd /var/www/mywebsite.com/ghost/ you can install New Relic with NPM: npm install newrelic.

The resulting file should be copied on the root directory: cp node_modules/newrelic/newrelic.js newrelic.js and then edited (you need to enter your app name and license key).

A nice trick suggested by the DiscoverGhost article previously mentioned, is including the New Relic script inside config.js, on the first line: require('newrelic');. Other tutorials suggest editing index.js but this means you will have to edit them again each time Ghost is upgraded.

Setting up the alert rules is rather straightforward. There's a page on the official documentation covering most of the basics: New Relic Downtime alert settings.

You will receive an email each time your Ghost blog is down, as well as when it comes back up again on its own so you can relax and stop fretting.

The combination between deploying Ghost with Forever, New Relic monitoring and custom error pages are more than enough for me. And although I no longer had errors lately, it's good to know you're covered!