Handling power outages with an uninterruptible power supply and NUT

The main reason for having a UPS is to protect against data loss due to power outages whether it be unsaved work, or corruption due to the computer not having enough time to write things to disk. I only really started to take this seriously when I got my Synology networked attached storage (NAS) which holds all my data.

The UPS I chose is an APC model with 1300VA and a USB connection, which is powerful enough to power most of the critical equipment I have at home and to ensure they have enough time to shut down. One of the advantages of having an uninterruptible power supply (UPS) with a USB connection is that it is possible to smartly shut down any computers during a power outage.

My strategy is when the UPS goes on battery, I want the Windows PC and Linux server to shut down immediately (well after a 1 minute timeout). These are the heaviest load (roughly 100W each on idle) on the UPS and they aren’t running anything really important that I need during a power outage; they just need to shutdown cleanly. The Synology NAS is a lighter load so I don’t mind keeping that one on and only shut it down when the UPS battery is low. Keeping the cable modem and wireless router allows me to continue to have network access which is critical for NUT to work, but also for general productivity in case of a prolonged failure). I’ve found in past outages that the cable equipment in my apartment building has some sort of separate or backup power source as well so generally the internet can continue to work. With just the cable modem, router and Synology the power draw is about 50W. I can manually shut down the NAS if I want to prolong the network even further.

What’s this NUT you keep talking about?

NUT stands for Network UPS Tools which are a set of utilities that are cross platform and cross manufacturer that monitors and responds to changes in UPS statuses. As we will see in the following sections, Synology NAS already has built in support for NUT, and NUT tools can be installed on Windows and Linux.

Continue Reading

Fixing missing categories and tags in WordPress’ block editor

For several months now, I’ve noticed that the Categories and Tags widgets were missing in my WordPress’s post block editor. It was sort of fine because I could work around it by assigning categories and tags through the Quick Edit functionality from the post list, but it was an annoyance.

I had done the usual debugging steps of disabling plugins, changing to the default theme, even reinstalling the core WordPress code, but nothing changed. I had tried searching online for phrases like “wordpress categories and tags missing” but didn’t come up with anything.

Today, I found two clues that led me to investigate this further. First, when I popped open Chrome’s developer tools, I noticed that the AJAX requests were firing nonstop. I was originally wanting to check whether there were errors in any of the requests, but the requests were all returning JSON responses, so there wasn’t any error in the processing aspect.

Second, I installed the Health Check & Troubleshooting plugin. When I ran it, it showed:

The REST API did not behave correctly

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

The REST API did not process the context query parameter correctly.

I happened to come across this blog post which suggested adding the following piece of configuration to the nginx configuration.

location ~ ^/wp-json/ {
    rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}

Lo and behold, it solved the problem! I haven’t dug into the details as to what exactly is going on. I’m just posting this in case other people come across this issue since it was not straight forward to find the resolution to this problem.

Side Project: Grouse Mountain Skyride Availability

I haven’t had time to work on many side projects lately. I think I generally am most effective at programming when I have a long stretch of uninterrupted time (on the order of a few hours or more at a time), and I have found the same at work. These long stretches of time are difficult to find these days.

However this was one opportunity that came up this week. Many of my side projects are born from automating repetitive manual tasks, and this was one of those.

Continue Reading

The virtue of hope

This was originally prepared as a reflection for a youth ministry session at St. Anthony of Padua parish.

“Hope” is a word we use a lot on a daily basis.  We say things like, “I hope you are doing well,” “I hope I get this job”, “I hope the restaurant has gluten-free food,” “I hope the pandemic will end soon.”  We hope for something which is difficult to attain ourselves.  We don’t say “I hope there will be air to breathe tomorrow,” because we expect there to be air.

But what does “hope” mean in the Christian sense?  What is the virtue of hope?  Ordering of one’s live in the ultimate sense towards God, towards final salvation.  Trust in God, extended into the future.

Continue Reading

Desktop computer v2

I’ve been wanting to build a new PC for a while. My current PC was originally built back in 2012, and upgraded in 2018. There’s still a lot of life left in this PC, so it will definitely be repurposed. However, for desktop use, it has fallen short in being unable to run a few modern applications (ok, also games) that I’ve been interested in, namely: DaVinci Resolve, the 2020 version of Microsoft Flight Simulator, and Call of Duty: Warzone.

Spending a lot more time at home due to the pandemic also drove my decision to upgrade the PC. But everyone else also has had the same idea over the past year, so demand was (and still continues to be) crazy high, and supply super low. I couldn’t be too picky about the parts.

I wanted to build something based on the AMD Ryzen 5 3600. For the most part, AMD still has the edge on better price to performance ratio, although with the current economic state of supply chain issues and shortages, that could be somewhat varied. One tradeoff though is that the AM4 socket is nearing the end of its lifecycle, which means significant future upgrades may be limited. On the GPU side of things, I was looking at the Nvidia GeForce GTX 1660 series. Both of my CPU and GPU choices are popular mid-range options that are last year’s generation, which means the prices shouldn’t be as high as the latest/upcoming generation freshly released.

Over the past month (from Black Friday through Boxing day deals), I managed to get the following components:

Type Item Price
CPU AMD Ryzen 5 3600 3.6 GHz 6-Core Processor $287.67
Motherboard MSI B550-A PRO ATX AM4 Motherboard $164.99
Memory Corsair Vengeance LPX 32 GB (2 x 16 GB) DDR4-3200 CL16 Memory $154.99
Storage Western Digital Blue SN550 1 TB M.2-2280 NVME Solid State Drive $119.99
Video Card Asus GeForce GTX 1660 SUPER 6 GB TUF GAMING OC Video Card $309.99
Case Corsair 100R ATX Mid Tower Case $54.99
Power Supply EVGA B5 550 W 80+ Bronze Certified Fully Modular ATX Power Supply $84.99
Total $1177.61

I don’t think anything in particular was significantly discounted at this time, however the name of the game was snagging the items before they went out of stock.

And here’s a comparison of the new CPU compared to my current PC’s past and current processors:

So far, I’m really happy with the build. It performs well for all the productive as well as entertainment purposes I had planned. I feel it’s going to be a great PC for the next few years, at least.