While running with docker-compose is usually simpler, you can run the bot on your server or local system.
- Python 3.10 or above
- Virtualenv
- Docker for running Postgres (or alternately, run it directly on your host too)
You will need a couple of specific system packages installed:
libpq
as a dependency of thepsycopg2
pip packagelibjpeg-dev
as a dependency of thePillow
pip package- (this is only here as a dependency of scipy, which is only used in the plotting script and not the running app)
You can install these on various OSes as described below:
sudo apt-get install libpq-dev libjpeg-dev
pacman -S postgresql-libs libjpeg-turbo
brew install postgresql jpeg
The steps below assume MacOS, Linux or WSL on Windows.
# Set up a new virtualenv (only needed first time)
python3 -m venv .venv
# Activate the virtualenv
source .venv/bin/activate
# Install python dependencies
pip install -e .
Start a local database with:
sudo docker run --name postgres -e POSTGRES_PASSWORD=password -d -p 5432:5432 postgres
To restart an existing docker container, use:
sudo docker restart postgres
Install postgresql-client
sudo apt-get install postgresql-client
To connect with PSQL:
PGPASSWORD=password psql -h localhost -U postgres -d postgres -p 5432
In .env
:
DATABASE_URI=postgresql://postgres:password@localhost:5432/postgres
From the root directory, with the database running,
# Activate the virtualenv
source .venv/bin/activate
# Run migrations and start the app
./startup.sh
git pull
alembic upgrade head
Then restart the python process.
Running within WSL and following the unix-like instructions is recommended.
If you see this error when activating the venv:
File <>\discord-bots\.venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
You may need to adjust your windows execution policy: https://stackoverflow.com/a/18713789