Django app to replace the Express/Mongo app that replaced the Meteor app... https://ausglamr.newcardigan.org
Go to file
2024-07-30 20:27:15 +10:00
ausglamr formatting 2024-06-24 12:23:01 +10:00
blogs fix faulty description appending code 2024-06-28 18:28:26 +10:00
.env.example another ridiculously large commit 2024-01-26 11:00:26 +11:00
.gitignore update docs and glamr-dev 2024-07-30 20:23:22 +10:00
.pylintrc initial commit 2024-01-04 11:54:56 +11:00
admin.py initial commit 2024-01-04 11:54:56 +11:00
docker-compose.yml update docs and glamr-dev 2024-07-30 20:23:22 +10:00
Dockerfile initial commit 2024-01-04 11:54:56 +11:00
glamr-dev update docs and glamr-dev 2024-07-30 20:23:22 +10:00
manage.py initial commit 2024-01-04 11:54:56 +11:00
nginx.conf.example update docs and glamr-dev 2024-07-30 20:23:22 +10:00
README.md update docs and glamr-dev 2024-07-30 20:23:22 +10:00
requirements.txt Update requirements.txt 2024-06-17 16:28:44 +10:00

Aus GLAMR

A django app running on Docker. Replaces Aus GLAM Blogs.

Deploy

  • cp .env.example .env and enter env values for your app
  • set up web server config (see nginx example)
  • docker compose build
  • ./glamr-dev migrate (you may get an error at this point - ignore)
  • ./glamr-dev createsuperuser
  • ./glamr-dev collectstatic
  • copy static files to where your webserver can find them, e.g./srv/ausglamr
  • docker compose up -d
  • set up cron jobs for management commands as outlined below

Admin

Don't forget to add some Content Warnings for use by the Mastodon bot, within /admin.

CLI tool

Use glamr-dev to make your life easier (thanks to Mouse Reeve for the inspiration):

  • announce
  • backup
  • check_feeds
  • manage [django management command]
  • makemigrations
  • migrate
  • queue_announcements
  • send_weekly_email

And for dev work:

  • black
  • collectstatic
  • createsuperuser
  • pylint
  • resetdb
  • test

Registration

  • users can register a blog, group, event, newsletter, or Call for Papers.
  • most of these ask for an "owner email" - this is optional but allows us to communicate with the person registering.
  • all registrations should trigger an email to admin
  • all must be approved before they are included

Management commands

There are four commands:

  • announce
  • check_feeds
  • queue_announcements
  • send_weekly_email

These will not be triggered within the app - they should be called via cron jobs.

announce

This posts the next queued announcement on Mastodon.

Run about every 20 mins.

check_feeds

This checks all blog feeds for any new posts, and adds them to the database as long as they don't have an exclusion tag and were not published during a time the blog was suspended.

Also checks newsletter articles if there is a feed.

Run every hour.

queue_announcements

This queues announcements for events and CFPs. These are announced three times, evenly spaced between when they were added and when the event starts or the CFP closes.

Run daily.

send_weekly_email

Does what you think. Creates a weekly email of the latest stuff, and send to everyone in Subscribers.

Run weekly.

Backups

Creating backups

There is a backup command in glamr-dev. The backup is named after the current day of the week, so in effect there will be a maximum of 7 rotating backups. The backup command relies on two environment variables: DOCKER_PATH and BACKUPS_DIR - you need to set these in your .env if you plan to run backups manually, but if you are running it with a cron job (recommended) you need to set environment variables within the crontab itself. See more details below.

Restoring backups

  1. back up your VPS if possible (e.g. taking a snapshot)
  2. Locate the latest backup, or run the backup program: ./glamr-dev backup
  3. copy database dump into the container: docker cp ~/ausglamr.dump ausglamr-db-1:/tmp/
  4. restore the dump: docker exec -d ausglamr-db-1 pg_restore -c -e -U ausglamr -d ausglamr /tmp/ausglamr.dump

Cron jobs

The obvious way to run the management and backup commands is via cron jobs. It's important to note that environment variables generally need to be set within the crontab - you can't rely on passing them in from Ausglamr nor from a user context. If you forget to to this they will be blank and one of the bad things that will happen is cron will try and fail to run the Unix program exec instead of docker exec when trying to run backups.

Below are suggested crontab settings and jobs for Ausglamr.

# Aus GLAMR
# ---------

# envs
PATH=/bin:/usr/bin:/usr/local/bin:/snap/bin
DOCKER_PATH=/usr/bin/docker
BACKUPS_DIR=/home/ausglamr/backups

# Announce thrice an hour
1,23,47 * * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev announce

# Check feeds hourly on the eleventh minute
11 * * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev check_feeds 

# Queue event announcements daily at 4:01am
1 4 * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev queue_announcements

# Run backups daily - 1:01am
1 1 * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev backup

# Send email weekly at 12:05pm
5 12 * * 1 cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev send_weekly_email