From 55ee5b53b6f60e74fe83e19ca15da5db1290b86f Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Fri, 23 Feb 2024 15:35:55 +1100 Subject: [PATCH] Add a basic script to "push" deploy Currently updates are published by the "conservancy-www-update.sh" that does a "pull" deploy with a 5-minutely job that runs on the web server. This doesn't run `migrate`, `collectstatic` or restart the application, so certain types of changes don't take effect, and even template changes often don't due to caching template loader. This script allows you to deploy more significant updates on-demand, but requires SSH access. --- {deploy => bin/deploy}/install.yml | 0 {deploy => bin/deploy}/inventory.ini | 0 {deploy => bin/deploy}/postfix/main.cf | 0 {deploy => bin/deploy}/systemd/README.md | 0 .../deploy}/systemd/conservancy-www-cleanup.service | 0 .../deploy}/systemd/conservancy-www-db.path | 0 .../deploy}/systemd/conservancy-www-db.service | 0 .../systemd/conservancy-www-linkchecker.service | 0 .../systemd/conservancy-www-linkchecker.timer | 0 .../deploy}/systemd/conservancy-www-update.service | 0 .../deploy}/systemd/conservancy-www-update.sh | 0 .../deploy}/systemd/conservancy-www-update.timer | 0 deploy.sh | 13 +++++++++++++ 13 files changed, 13 insertions(+) rename {deploy => bin/deploy}/install.yml (100%) rename {deploy => bin/deploy}/inventory.ini (100%) rename {deploy => bin/deploy}/postfix/main.cf (100%) rename {deploy => bin/deploy}/systemd/README.md (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-cleanup.service (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-db.path (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-db.service (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-linkchecker.service (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-linkchecker.timer (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-update.service (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-update.sh (100%) rename {deploy => bin/deploy}/systemd/conservancy-www-update.timer (100%) create mode 100755 deploy.sh diff --git a/deploy/install.yml b/bin/deploy/install.yml similarity index 100% rename from deploy/install.yml rename to bin/deploy/install.yml diff --git a/deploy/inventory.ini b/bin/deploy/inventory.ini similarity index 100% rename from deploy/inventory.ini rename to bin/deploy/inventory.ini diff --git a/deploy/postfix/main.cf b/bin/deploy/postfix/main.cf similarity index 100% rename from deploy/postfix/main.cf rename to bin/deploy/postfix/main.cf diff --git a/deploy/systemd/README.md b/bin/deploy/systemd/README.md similarity index 100% rename from deploy/systemd/README.md rename to bin/deploy/systemd/README.md diff --git a/deploy/systemd/conservancy-www-cleanup.service b/bin/deploy/systemd/conservancy-www-cleanup.service similarity index 100% rename from deploy/systemd/conservancy-www-cleanup.service rename to bin/deploy/systemd/conservancy-www-cleanup.service diff --git a/deploy/systemd/conservancy-www-db.path b/bin/deploy/systemd/conservancy-www-db.path similarity index 100% rename from deploy/systemd/conservancy-www-db.path rename to bin/deploy/systemd/conservancy-www-db.path diff --git a/deploy/systemd/conservancy-www-db.service b/bin/deploy/systemd/conservancy-www-db.service similarity index 100% rename from deploy/systemd/conservancy-www-db.service rename to bin/deploy/systemd/conservancy-www-db.service diff --git a/deploy/systemd/conservancy-www-linkchecker.service b/bin/deploy/systemd/conservancy-www-linkchecker.service similarity index 100% rename from deploy/systemd/conservancy-www-linkchecker.service rename to bin/deploy/systemd/conservancy-www-linkchecker.service diff --git a/deploy/systemd/conservancy-www-linkchecker.timer b/bin/deploy/systemd/conservancy-www-linkchecker.timer similarity index 100% rename from deploy/systemd/conservancy-www-linkchecker.timer rename to bin/deploy/systemd/conservancy-www-linkchecker.timer diff --git a/deploy/systemd/conservancy-www-update.service b/bin/deploy/systemd/conservancy-www-update.service similarity index 100% rename from deploy/systemd/conservancy-www-update.service rename to bin/deploy/systemd/conservancy-www-update.service diff --git a/deploy/systemd/conservancy-www-update.sh b/bin/deploy/systemd/conservancy-www-update.sh similarity index 100% rename from deploy/systemd/conservancy-www-update.sh rename to bin/deploy/systemd/conservancy-www-update.sh diff --git a/deploy/systemd/conservancy-www-update.timer b/bin/deploy/systemd/conservancy-www-update.timer similarity index 100% rename from deploy/systemd/conservancy-www-update.timer rename to bin/deploy/systemd/conservancy-www-update.timer diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 00000000..6a1fc312 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +ssh debian@hickory.sfconservancy.org 'bash -s' << EOF +set -x # Show output +set -e # Abort on failure +cd /var/www/website +sudo -u www-data git pull +sudo -u www-data /var/www/venv-website/bin/python manage.py check +sudo -u www-data /var/www/venv-website/bin/python manage.py migrate +sudo -u www-data /var/www/venv-website/bin/python manage.py collectstatic -v0 --noinput --link +sudo systemctl restart apache2 +curl --silent --head https://sfconservancy.org | grep --perl-regexp "^HTTP/.+ 200" +EOF