Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 1.64 KB

README.md

File metadata and controls

64 lines (51 loc) · 1.64 KB

Test Application

A Django application with Celery task queue integration, using PostgreSQL and RabbitMQ.

Prerequisites

Quick Start

  1. Clone and Setup Environment
git clone <repository-url>
cd <repository-name>
conda env create -f environment.yml
conda activate test-app
  1. Configure Environment Copy the .env.template file to create your .env:
cp .env.template .env

Then modify the values in .env according to your needs.

  1. Configure PostgreSQL
# First-time setup
mkdir -p $CONDA_PREFIX/var/{postgres,run/postgresql}
initdb -D $CONDA_PREFIX/var/postgres
echo "unix_socket_directories = '$CONDA_PREFIX/var/run/postgresql'" >> $CONDA_PREFIX/var/postgres/postgresql.conf

# Start PostgreSQL
pg_ctl -D $CONDA_PREFIX/var/postgres start

# Create database and user
export $(cat .env | grep -v '^#' | xargs)
createdb -h $CONDA_PREFIX/var/run/postgresql $POSTGRES_DB
psql -h $CONDA_PREFIX/var/run/postgresql -d $POSTGRES_DB << EOF
CREATE USER $POSTGRES_USER WITH PASSWORD '$POSTGRES_PASSWORD';
ALTER USER $POSTGRES_USER WITH CREATEDB;
GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;
GRANT ALL ON SCHEMA public TO $POSTGRES_USER;
ALTER SCHEMA public OWNER TO $POSTGRES_USER;
EOF
  1. Run the Application In separate terminals (with conda activate test-app):
# Terminal 1: RabbitMQ
rabbitmq-server

# Terminal 2: Django
python manage.py migrate
python manage.py runserver

# Terminal 3: Celery
celery -A app worker -l INFO -c 1

Access the application: