Fix maintenance tasks failing to run in production. In production they were losing the database connection and not re-establishing it, so they couldn't queue jobs. `ApplicationRecord.verify!` will check if the connection is lost and re-establish it if it is. The database connection was being lost because in production we use a Kubernetes service IP for the database IP, which is essentially a virtual IP that maps to the real IP. This mapping is implemented with IPVS[1][2], which has a default idle connection timeout of 5 minutes. If the connection isn't used for more than 5 minutes, then it's closed. Since maintenance only runs once an hour, the database connection would be lost because it was idle for too long. 1: https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-ipvs 2: https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/
Logical
This directory contains library code used through Danbooru. This includes things like defining API clients, dealing with sources, parsing tag searches, storing and resizing images, and so on.
Many of the files here use the Service Object pattern. Instead of putting complex code in models or controllers, it goes here, in plain old Ruby objects (POROs). This keeps models and controllers simpler, and keeps domain logic isolated and independent from the database and the HTTP request cycle.