GithubHelp home page GithubHelp logo

openttd / master-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 1.0 156 KB

In-game and web-based listing of online OpenTTD servers

License: GNU General Public License v2.0

Dockerfile 2.34% Python 97.66%

master-server's Introduction

Master Server

GitHub License

This repository contains two components to have a functional Master Server for the OpenTTD clients.

  1. a master_server component, which runs the actual Master Server and communicates with the OpenTTD clients.
  2. a web_api component, which allows HTTP access to the current online servers known by the Master Server.

These are in a single repository, as they share the same database access.

Development

The master_server and web_api are written in Python 3.8, and makes strong use of asyncio and aiohttp.

Both make use of the AWS DynamoDB database to store the known servers.

Running a local server

Dependencies

  • Python3.8 or higher.
  • Docker

Preparing your venv

To start it, you are advised to first create a virtualenv:

python3 -m venv .env
.env/bin/pip install -r requirements.txt

Preparing docker

You need to run a local AWS DynamoDB to experiment with. AWS supplies a version via Docker (you can also run it via Java; this is left as an exercise to the reader):

docker run --rm -p 8000:8000 amazon/dynamodb-local

This will start an empty AWS DynamoDB server on port 8000.

Starting master_server

You can start the master_server by running:

AWS_ACCESS_KEY_ID=1 AWS_SECRET_ACCESS_KEY=1 .env/bin/python -m master_server --app master_server --web-port 8081 --db dynamodb --dynamodb-host http://127.0.0.1:8000

This will start the server on port 3978 (default) for you to work with locally. The webserver on port 8081 is just to monitor the health of the server. You can change your /etc/hosts or C:\Windows\System32\drivers\etc to map master.openttd.org to 127.0.0.1 and ::1 for local testing.

Starting web_api

You can start the web_api by running:

AWS_ACCESS_KEY_ID=1 AWS_SECRET_ACCESS_KEY=1 .env/bin/python -m master_server --app web_api --web-port 8080 --db dynamodb --dynamodb-host http://127.0.0.1:8000

This will start the HTTP server on port 8080 for you to work with locally. It does require some servers to be in the database to be useful, so make sure to start a master_server locally and run a (dedicated) server to add an entry.

Running via docker

docker build -t openttd/master-server:local .
docker run --rm --name ms-dynamodb -p 8000:8000 amazon/dynamodb-local
docker run --rm --link ms-dynamodb -p 127.0.0.1:3978:3978/udp -p 127.0.0.1:8081:80 -e AWS_ACCESS_KEY_ID=1 -e AWS_SECRET_ACCESS_KEY=1 openttd/master-server:local --app master_server --bind 0.0.0.0 --db dynamodb --dynamodb-host http://ms-dynamodb:8000
docker run --rm --link ms-dynamodb -p 127.0.0.1:8080:80 -e AWS_ACCESS_KEY_ID=1 -e AWS_SECRET_ACCESS_KEY=1 openttd/master-server:local --app web_api --bind 0.0.0.0 --db dynamodb --dynamodb-host http://ms-dynamodb:8000

This will start an empty AWS DynamoDB, the Master Server listing on UDP 3978 and the Web API on HTTP port 8080.

master-server's People

Contributors

dependabot[bot] avatar pyup-bot avatar truebrain avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

truebrain

master-server's Issues

Switch to openttd-protocol

Currently this repository implements its own protocol handler. There is a repository (https://github.com/OpenTTD/py-protocol) that unifies this between all our Python components.

Please switch to using that. It mostly means moving the openttd folder to that library, and remove what is not needed.

This also allows access to enums, meaning we can remove hard-coded values (and their comments) and replace them with the correct enum.

Allow settings a table name prefix

The table names are now hardcoded. In a deployment scenario this means staging and production use the same table names. This is not ideal.

Additionally, by mistake a developer with sufficient credentials can use the production database.

All in all, table names should contain a prefix of the environment they are running in.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.