Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Backend code forhttps://avrae.io

License

NotificationsYou must be signed in to change notification settings

avrae/avrae-service

Repository files navigation

Avrae is a bot to facilitate running Dungeons & Dragons 5e online over Discord. This project is the backend to serveavrae.io.

You can join the Avrae Development Discordhere!

Requirements

  • Python 3.10+
  • MongoDB server
  • Redis server

See the README in avrae/avrae for additional instructions and links to dependencies.

Running

Configuration

The development config defaults to the MongoDB/Redis servers run byAvrae DockerCompose.

  1. Copydocker/config-development.py toconfig.py.
  2. The dev config should point to the services exposed by the Avrae docker-compose file. If necessary, set theenvironment variablesMONGO_URL andREDIS_URL to override connection strings.
  3. Set theDISCORD_CLIENT_ID,DISCORD_CLIENT_SECRET, andDISCORD_BOT_TOKEN environment variables to the values foryour application, found in theDiscord Developer Portal.
  4. Set theJWT_SECRET env var to any value of your choice.

Env Var Overview

  • MONGO_URL - Override connection string to MongoDB, defaults to exposed instance from avrae/avrae docker compose
  • REDIS_URL - Override connection string to Redis, defaults to exposed instance from avrae/avrae docker compose
  • DISCORD_CLIENT_ID - Discord application Client ID (Dev Portal -> Application -> OAuth2)
  • DISCORD_CLIENT_SECRET - Discord application Client Secret (Dev Portal -> Application -> OAuth2)
  • DISCORD_BOT_TOKEN - Discord application Bot User Token (Dev Portal -> Application -> Bot)
  • JWT_SECRET - Used to sign JWTs issued by the service
  • ELASTICSEARCH_ENDPOINT (optional) - Used to specify URL of an ElasticSearch instance for Alias Workshop

ElasticSearch

The Avrae service requires ElasticSearch for some features (e.g. searching alias workshop collections). You shouldeither set up a dev ElasticSearch instance on AWS, or run an openElasticSearch distro.

Whichever you choose, set theELASTICSEARCH_ENDPOINT env var. The service will work without this set, but AliasWorkshop endpoints might have undefined behaviour.

Running locally

  1. Create avirtual environment:python3 -m venv venv.
  2. Activate the venv:source venv/bin/activate on Unix (bash/zsh),venv\Scripts\activate.bat on Windows.
  3. Install the required Python packages:pip install -r requirements.txt.
  4. Run the app:python -m flask run.

The service should now be accessible athttp://localhost:5000.

Should you have authentication errors and DB not loading locally, you can update line 38 in app.py to the below.

app.mdb = mdb = PyMongo(app, config.MONGO_URL).cx["avrae"]

Running locally with Docker

  1. Build the Docker image:docker build -t avrae-service:latest --build-arg ENVIRONMENT=development ..
  2. Run the Docker image:docker run -p 58000:8000 avrae-service:latest.

The service should now be accessible athttp://localhost:58000.

Running in production

  1. Build the Docker image:docker build -t avrae-service:latest.
  2. Deploy it in whatever fashion your production environment requires.

The service should now be accessible athttp://IP.ADDRESS:8000.

Committing, Formatting, and Linting

Avrae usesBlack to format and lint its Python code.Black is automatically run on every commit via pre-commit hook, and takes its configuration options from thepyproject.toml file.

The pre-commit hook is installed by by runningpre-commit install from the repo root.The hook's configuration is governed by the.pre-commit-config.yaml file.

Dependencies

In order to runpre-commit orblack, they must be installed.These dependencies are contained within therequirements.txt file, and can be installed like so:

(venv) $ pip install -r requirements.txt

[8]ページ先頭

©2009-2025 Movatter.jp