working base site setup with gatekeeping working
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Production startup script (for systemd or manual)
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DJANGO_DIR="$SCRIPT_DIR/nonpacks"
|
||||
PYTHON_BIN="$SCRIPT_DIR/venv/bin/python"
|
||||
GUNICORN_BIN="$SCRIPT_DIR/venv/bin/gunicorn"
|
||||
|
||||
FLAG_FILE="$SCRIPT_DIR/.migrations_done"
|
||||
FORCE_SETUP=0
|
||||
|
||||
# Check for --force-setup argument
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--force-setup" ]; then
|
||||
FORCE_SETUP=1
|
||||
fi
|
||||
done
|
||||
|
||||
cd "$DJANGO_DIR"
|
||||
|
||||
# Run migrations once, flag it, skip next time
|
||||
if [ ! -f "$FLAG_FILE" ] || [ $FORCE_SETUP -eq 1 ]; then
|
||||
echo "Running database migrations..."
|
||||
"$PYTHON_BIN" manage.py migrate
|
||||
touch "$FLAG_FILE"
|
||||
echo "Migrations applied. Flag file created: $FLAG_FILE"
|
||||
else
|
||||
echo "Database already migrated (found $FLAG_FILE). Skipping."
|
||||
echo "To force re-run, use: $0 --force-setup"
|
||||
fi
|
||||
|
||||
# Collect static files (served by gunicorn via whitenoise)
|
||||
"$PYTHON_BIN" manage.py collectstatic --noinput
|
||||
|
||||
echo "Starting Gunicorn on 0.0.0.0:8000..."
|
||||
exec "$GUNICORN_BIN" \
|
||||
--workers 3 \
|
||||
--bind 0.0.0.0:8000 \
|
||||
common.wsgi:application
|
||||
Reference in New Issue
Block a user