Ghost upgrades and the Nginx 502's

Published on July 03, 2018 under Projects

If you weren't already aware, I use Ghost to power this website - I've been a fan of Ghost for quite some time mostly because it does exactly what I want it to do and I don't have to hack it nine ways from Sunday. I've used multiple platforms to maintain the various websites I own and Ghost just kind of... works?

I've run into a few issues from the time I started using Ghost until now. I will fully admit I am learning as I go but they're definitely making it much easier progressively.

Today's issue was a standard 502 you may reicieve when you give your VPS/Dedicated/what-have-you a good old CLI

(I will typically use init 6 personally as I've never been much a fan of shutdown -r by itself.)

init 6 tells the init process to shutdown all of the spawned processes/daemons as written in the init files (in the inverse order they started) and lastly invoke the shutdown -r now command to reboot the machine

This time, however, it was persistent and wouldn't go away, after running Ghost doctor and messing about with my distros recent upgrades and the like I decided I'd give something else a shot.

Having upgraded my Ghost installation just yesterday and not noticing there was something going on, I don't often check on the welfare of my website while I am at work. I thought it was strange I was getting a 502 just pulling up Fractal Continuum on my phone so I investigated!

It turns out the issue wasn't any updates/upgrades my distro had done, more so it was an issue with how the Ghost upgrade installation was processed - in short, it wasn't. Luckily, the work around for this is incredibly easy to deal with!


Command: ghost update

ghost-mgr@ghost:/var/www/ghost$ ghost doctor
✔ Checking system Node.js version
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
Running sudo command: systemctl is-active ghost_206-81-6-78
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
ghost-mgr@ghost:/var/www/ghost$ ghost update
Running sudo command: systemctl is-active ghost_206-81-6-78
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking for available migrations
✔ Checking for latest Ghost version
All up to date!

This was my first attempt to resolve the issue - however, it didn't work because there was an issue with the original upgrade. My installation was reflecting what Ghost had as the proper version regardless of functionality.

It took me a bit of time to come up with a more... conventionally unconventional means to troubleshoot the issue and perhaps resolve things before I pulled the few remaining hairs on my head from the root.

I thought to myself.. perhaps if I --force things... it may actually work and overwrite whichever files may be having issues.


Command: ghost update --force

ghost-mgr@ghost:/var/www/ghost$ ghost update --force
Running sudo command: systemctl is-active ghost_206-81-6-78
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking for available migrations
✔ Checking for latest Ghost version
✔ Downloading and updating Ghost to v1.24.7
Running sudo command: systemctl is-active ghost_206-81-6-78
Running sudo command: systemctl stop ghost_206-81-6-78
✔ Stopping Ghost
✔ Linking latest Ghost and recording versions
Running sudo command: /var/www/ghost/current/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current
✔ Running database migrations
Running sudo command: systemctl is-active ghost_206-81-6-78
☱ Running database migrations✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
Running sudo command: systemctl is-active ghost_206-81-6-78
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
Running sudo command: systemctl start ghost_206-81-6-78
✔ Restarting Ghost
ℹ Removing old Ghost versions [skipped]

ghost update --foce was the solution to my problems here as my Nginx configuration hadn't changed, my server was still functioning as normal.

This may not be your exact problem, I have never personally run into this issue though - it would typically fall under the idea of improper folder permissions or npm not functioning properly in --production. However, if this is your problem and this does help you out, that's awesome!


End.

Jason Michael Author

A developer/musician from Boston, Massachusetts just trying to find his place in the world through code, keys, and various other bizarre mediums.

Fractal Continuum © 2018
Proudly hosted by Digital Ocean