Skip to content

Latest commit

 

History

History
102 lines (83 loc) · 4.42 KB

README.md

File metadata and controls

102 lines (83 loc) · 4.42 KB

backend

Installation

  1. Clone the repository
  2. Install poetry
  3. Run poetry install in the backend directory
  4. If necessary, install PostgreSQL
  5. Create a new database. If desired, an existing database can also be used, provided there are no name conflicts with this application, though this is not recommended
  6. In your chosen database, run all .sql files in the sql/ directory, starting with tables.sql
  7. Wherever the environment for the desired user is configured, set the DATABASE_URL variable to the connection URI for your database. Note that DATABASE_URL follows the variable used in heroku applications

NOTE: If the server is handling a large number of simultaneous connections, it will be limited by the system open file limit, which may be set to a small value by default on your system. If you are exceeding the limit, you will see error messages like the following:

OSError: [Errno 24] Too many open files

You can check the current value on linux with ulimit -n and set it for the current session with ulimit -n limit, up to any limits described in /etc/security/limits.conf. See this page for additional details.

NOTE: As database connections are made via TCP/IP, a password is required for all users by default. If you intend to connect without a password, you must edit pg_hba.conf to trust the desired user on the loopback address by adding a line like

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    my_db           postgres        127.0.0.1/32            trust

If you don't know the location of pg_hba.conf, connect to the database and run show hba_file;

python version requirement

≥ 3.9

PostgreSQL version requirement

13.3 tested, but all supported versions will likely work

Running locally

Run poetry run python -m igo.gameserver from the root directory. If running the AI server, separately run poetry run python -m igo.aiserver. Use the --help option on either for additional options. You will also need an instance of the frontend server running in order to play.

Technologies used

Production

  • aiofiles for reading local files asynchronously
  • asyncinit for writing async __init__ methods
  • asyncpg for performant, asynchronous communication with the PostgreSQL store
  • dataclassy for an auto-slotting reimplementation of python dataclasses that allows default attribute values and mutable defaults. __slots__ is especially useful for classes with many instances being created and destroyed, e.g. the message containers that are used in this codebase
  • PostgreSQL for a highly scalable store with asynchronous pub/sub capabilities for message passing
  • tornado for highly scalable, asynchronous WebSockets to communicate with the frontend and between the game and AI servers
  • uvloop for improved asyncio performance

Development