Lantern is a Django application for managing application-level services for Khoj.
You should have Docker and Docker Compose installed on your system for quickest setup.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export DJANGO_DEBUG=True
- Install Postgres
brew install postgresql@15
- Start Postgres
brew services start postgresql@15
- Install utilities
brew install libpq
Add to PATH
# ~/.zshrc
export PATH="/Applications/homebrew/opt/libpq/bin:$PATH"
Create role
createuser -s postgres
Create database
createdb lantern -U postgres
gunicorn -c config/gunicorn/dev.py
If you started the process in daemon mode, you can get the pid in the .pid
file under config/gunicorn
. Then run:
kill -9 <pid>
docker build -t lantern .
Docker Container
docker-compose up -d
docker exec -it lantern-web-1 bash
python manage.py migrate
- Install Profiling packages
Make sure that you have the following Python packages installed:
django-extensions==3.2.3
snakeviz==2.2.0
- Add debugging configuration in VSCode
In your launch.json
, add the following configuration:
{
"name": "Lantern - Profile",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runprofileserver", "0.0.0.0:5000", "--use-cprofile", "--prof-path", "${workspaceFolder}/profile"
],
"django": true,
"justMyCode": true
}
- Add a
/profile
folder to your projects root directory if it doesn't already exist - Make queries as normal
The binary output to represent the profile of individual queries should be outputted to the /profile
directory you've created
- Open the profiler visualizer
From your terminal, run snakeviz profile
in the root directory of the project.