The official Python Daemon of Cryptic
The documentation can be found on GitHub Pages.
If you want to build the documentation yourself, use the docs
script:
pipenv sync --dev
pipenv run docs
Note that you need to have Docker installed for this!
- Python >=3.9
- Pipenv
- Black
- Git
- Docker and docker-compose (recommended)
- PyCharm Community/Professional (recommended)
- An instance of the Cryptic Java Server (recommended)
git clone [email protected]:cryptic-game/python-daemon.git
git clone https://github.com/cryptic-game/python-daemon.git
Once you have cloned the repository, you need to create a virtual environment and install the dependencies using the following command:
pipenv sync --dev
To set the required environment variables it is necessary to create a file named (exactly) .env
in the root directory (there is a template for this file in daemon.env
).
Variable Name | Description | Default Value |
---|---|---|
LOG_LEVEL | one of DEBUG , INFO , WARNING , ERROR , CRITICAL |
INFO |
HOST | Host for the uvicorn server to listen on | 0.0.0.0 |
PORT | Port for the uvicorn server to listen on | 8000 |
RELOAD | Enable uvicorn auto-reload (for development purposes only!) | False |
DEBUG | Enable debug mode | False |
API_TOKEN | Secret api token for server-daemon communication | |
SQL_DRIVER | Name of the SQL connection driver | postgresql+asyncpg |
SQL_HOST | Hostname of the database server | localhost |
SQL_PORT | Port on which the database server is running | 5432 |
SQL_DATABASE | Name of the database you want to use | cryptic |
SQL_USERNAME | Username for the database account | cryptic |
SQL_PASSWORD | Password for the database account | cryptic |
POOL_RECYCLE | Number of seconds between db connection recycling | 300 |
POOL_SIZE | Size of the connection pool | 20 |
MAX_OVERFLOW | The maximum overflow size of the connection pool | 20 |
SQL_SHOW_STATEMENTS | whether SQL queries should be logged | False |
SQL_CREATE_TABLES | whether to create database tables on startup | False |
REDIS_HOST | Hostname of the redis server | redis |
REDIS_PORT | Port on which the redis server is running | 6379 |
REDIS_DB | Index of the redis database you want to use | 0 |
SENTRY_DSN | [Optional] Sentry DSN for logging |
Project
├── daemon
│ ├── endpoints
│ │ ├── __init__.py
│ │ └── <endpoint collection>.py
│ ├── exceptions
│ │ ├── api_exception.py
│ │ └── <endpoint collection>.py
│ ├── models
│ │ └── <endpoint collection>.py
│ └── schemas
│ ├── <endpoint collection>.py
│ ├── daemon.py
│ └── ok.py
└── tests
├── endpoints
│ ├── __init__.py
│ └── test_<endpoint collection>.py
└── test_<...>.py
- Open PyCharm and go to
Settings
➔Project: python-daemon
➔Python Interpreter
- Open the menu
Python Interpreter
and click onShow All...
- Click on the plus symbol
- Click on
Pipenv Environment
- Select
Python 3.9
asBase interpreter
- Confirm with
OK
- Change the working directory to root path ➔
Edit Configurations
➔Working directory
To run the Python Daemon yourself, use the daemon
script:
pipenv run daemon
Before committing your changes, please check that all unit tests are passing, reformat your code using black and run the linter:
pipenv run test
pipenv run black
pipenv run flake8