Skip to content

Commit b55127f

Browse files
author
Konstantin Kalinovsky
committed
Tick understanding
1 parent e75759b commit b55127f

23 files changed

+314
-209
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Created by .ignore support plugin (hsz.mobi)
21
*.pyc
32
*__pycache__*
43
.cache/*

.gitmodules

-3
This file was deleted.

Dockerfile

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
FROM python:3.6
1+
FROM python:3.6-slim
22

33
LABEL maintainer="FAF Community"
4-
LABEL version="0.4.2"
4+
LABEL version="0.4.6"
55
LABEL description="Forged Alliance Forever: Replay server"
66

7-
ENV PYTHON_VERSION 3.6.6
8-
ENV PYTHON_PIP_VERSION 18.0
9-
107
EXPOSE 15000
118

129
COPY . /var/faf-aio-replayserver
13-
RUN pip3 install -r /var/faf-aio-replayserver/requirements.txt
10+
RUN apt-get update && apt-get install -y git && \
11+
pip3 install pipenv && \
12+
cd /var/faf-aio-replayserver && pipenv install --deploy --system && \
13+
apt-get remove -y git libicu-dev libicu57 gcc-6 g++-6 python3-pip && \
14+
apt-get autoremove -y
1415

1516
CMD /var/faf-aio-replayserver/run.sh

Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ pytest-cov = "==2.5.1"
99
pytest-timeout = "==1.3.1"
1010
pytest-asyncio = "==0.9.0"
1111
bugsnag = "==3.4.2"
12+
replay-parser = {git = "https://github.com/FAForever/faf-scfa-replay-parser.git", editable = true}

Pipfile.lock

+78-79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coverage.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ pyclean .
44
rm -r tmp/*
55
rm -r replays/*
66

7-
DATABASE_WRITE_WAIT_TIME=0.1 REPLAY_TIMEOUT=1 python3.6 -m pytest --cov=replay_server --cov-report=html -rxs `find ./tests/fixtures/ ./tests/server/ ./tests/conftest.py -iname "*.py"`
7+
DATABASE_WRITE_WAIT_TIME=0.1 REPLAY_TIMEOUT=1 python3.6 -m pytest --cov=replay_server -rxs `find ./tests/fixtures/ ./tests/server/ ./tests/conftest.py -iname "*.py"`

docker-build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

3-
docker build --rm=true --tag=faf-aio-replayserver .
3+
docker build --rm=true --tag=faforever/faf-aio-replayserver .
44
echo "Docker container has been build 'faf-aio-replayserver'"

docker-run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
VERSION=`grep "LABEL version" Dockerfile | cut -d'"' -f2`
4-
IMAGE_VERSION="faf-aio-replayserver:$VERSION"
4+
IMAGE_VERSION="faforever/faf-aio-replayserver:$VERSION"
55

66
docker stop faf-aio-replayserver
77
docker rm faf-aio-replayserver

livetest.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ REPLAY_TIMEOUT=0 PYTHONPATH=$DIR python3.6 $DIR/replay_server/__main__.py &
1212
SERVER_PID=$!
1313
sleep 1
1414

15-
LIVE_TEST=1 DATABASE_WRITE_WAIT_TIME=0.1 REPLAY_TIMEOUT=1 python3.6 -m pytest -rxs `find ./tests/conftest.py ./tests/fixtures/ ./tests/live_server/ -iname "*.py"`
15+
LIVE_TEST=1 DATABASE_WRITE_WAIT_TIME=0.1 REPLAY_TIMEOUT=1 python3.6 -m pytest --cov=replay_server -rxs `find ./tests/conftest.py ./tests/fixtures/ ./tests/live_server/ -iname "*.py"`
1616

1717
kill $SERVER_PID

replay_server/connection.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def determine_type(self) -> Optional[int]:
3434
"""
3535
Determines which action client is asking for.
3636
"""
37-
logger.debug("Determining action type")
37+
logger.debug("<%s> Determining action type", self)
3838
try:
3939
action = await self.get_type()
4040
if action is None:
@@ -47,7 +47,7 @@ async def get_replay_name(self) -> Tuple[int, str]:
4747
"""
4848
Parses request and returns uid & name
4949
"""
50-
logger.debug("Getting replay name")
50+
logger.debug("<%s> Getting replay name", self)
5151
try:
5252
line = (await self.reader.readuntil(TERMINATOR))[:-1].decode()
5353
self.uid, self.game_name = line.split("/", 1)
@@ -62,6 +62,9 @@ async def get_replay_name(self) -> Tuple[int, str]:
6262
raise ConnectionError("Replay name: Unexpected data received")
6363

6464
async def close(self):
65-
logger.debug("Closing connection...")
65+
logger.debug("<%s> Closing connection...", self)
6666
self.writer.close()
67-
logger.debug("Connection closed")
67+
logger.debug("<%s> Connection closed", self)
68+
69+
def __str__(self):
70+
return str(id(self))

replay_server/constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
WAIT_STEP = 0.1 # in seconds, it might influence fluent streaming, default is 0.1
1414
# Wait timeout, till we will send live stream back
1515
REPLAY_TIMEOUT = int(os.environ.get("REPLAY_TIMEOUT", 60 * 5))
16-
READ_BUFFER_SIZE = int(os.environ.get("READ_BUFFER_SIZE", 1024))
16+
READ_BUFFER_SIZE = 65535 + 1 + 2 # 65535 max tick size + 1 for type + 2 for tick content size
17+
TICK_COUNT_TIMEOUT = 3000 # 5 minutes * 10 tick per sec
1718
WRITE_BUFFER_SIZE = int(os.environ.get("WRITE_BUFFER_SIZE", 1024))
1819
DATABASE_WRITE_WAIT_TIME = float(os.environ.get("DATABASE_WRITE_WAIT_TIME", 10))
1920
# base for uploading streams

replay_server/replay_parser

-1
This file was deleted.

0 commit comments

Comments
 (0)