Skip to content

Commit

Permalink
refactor: move etc/ to conf/
Browse files Browse the repository at this point in the history
  • Loading branch information
anorthall committed Feb 7, 2025
1 parent cfae206 commit 2f02240
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 76 deletions.
File renamed without changes.
77 changes: 77 additions & 0 deletions conf/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
CONF_ROOT="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT_ROOT="${CONF_ROOT}/.."
APP_ROOT="${PROJECT_ROOT}/reportdb"

if [ -z "$VIRTUAL_ENV" ]
then
echo "VIRTUAL_ENV is not set. Attempting to activate..."
source "$PROJECT_ROOT/.venv/bin/activate"
fi

if [ "$1" = "manage" ]
then
cd "$APP_ROOT" || exit 1
python manage.py "${@:2}"
fi

if [ "$1" = "test" ]
then
cd "$APP_ROOT" || exit 1
python manage.py test "${@:2}"
exit 0
fi

# Run a development server which runs workers within the same
# docker container within a separate process for quicker builds
# and less RAM usage.
if [ "$1" = "devserver" ]
then
echo "Collecting static files..."
cd "$APP_ROOT" || exit 1
python manage.py collectstatic --noinput

if [ "$RUN_MIGRATIONS_ON_START" = "yes" ]
then
echo "Running migrations..."
python manage.py migrate --no-input
fi

cd "$PROJECT_ROOT" || exit 1
echo "Starting server..."

# shellcheck disable=SC2030
granian --interface wsgi \
--host 0.0.0.0 \
--port "${PORT:=8000}" \
--workers 1 \
--respawn-failed-workers \
--reload \
--reload-paths backend/src \
--no-ws \
--threading-mode workers \
conf.wsgi:application &
fi

# Run production server
if [ "$1" = "start" ]
then
cd "$APP_ROOT" || exit 1

echo "Collecting static files..."
python manage.py collectstatic --no-input

cd "$PROJECT_ROOT" || exit 1
echo "Starting server..."
# shellcheck disable=SC2031
granian --interface wsgi \
--host 0.0.0.0 \
--port "${PORT:=8000}" \
--workers 4 \
--respawn-failed-workers \
--no-reload \
--no-ws \
--threading-mode workers \
--workers-lifetime 600 \
conf.wsgi:application &
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
db:
image: postgres:16.0
image: postgres:17
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
Expand All @@ -16,7 +16,7 @@ services:
ports:
- "8000:8000"
env_file:
- etc/dev.env
- conf/dev.env
depends_on:
- db

Expand Down
59 changes: 0 additions & 59 deletions etc/run.sh

This file was deleted.

Empty file removed reportdb/reportdb/__init__.py
Empty file.
15 changes: 0 additions & 15 deletions reportdb/reportdb/asgi.py

This file was deleted.

0 comments on commit 2f02240

Please sign in to comment.