#!/bin/bash
set -eu

PROJECT_PATH=/var/www/neuf.no/bbs
PROCESS_NAME="$PROJECT.neuf.no"

cd "$PROJECT_PATH" || exit 1
git pull
poetry install
umask 022; poetry run python manage.py collectstatic --noinput  # Collect static
poetry run python manage.py migrate  # Run DB migrations

# Reload
sudo /usr/bin/supervisorctl pid "$PROCESS_NAME" | xargs kill -HUP
