diff --git a/main.py b/main.py index 18bf95d26..0c5f90592 100755 --- a/main.py +++ b/main.py @@ -10,7 +10,6 @@ import asyncio import logging import os -import platform import signal import sys import time @@ -22,6 +21,7 @@ from prometheus_client import start_http_server import server +from server import info from server.config import config from server.control import ControlServer from server.game_service import GameService @@ -44,14 +44,12 @@ def wrapped(sig, frame): async def main(): global startup_time, shutdown_time - version = os.environ.get("VERSION") or "dev" - python_version = platform.python_version() - logger.info( - "Lobby %s (Python %s) on %s", - version, - python_version, - sys.platform + "Lobby %s (Python %s) on %s named %s", + info.VERSION, + info.PYTHON_VERSION, + sys.platform, + info.CONTAINER_NAME, ) if config.ENABLE_METRICS: @@ -151,8 +149,8 @@ def done_handler(sig: int, frame): ) server.metrics.info.info({ - "version": version, - "python_version": python_version, + "version": info.VERSION, + "python_version": info.PYTHON_VERSION, "start_time": datetime.utcnow().strftime("%m-%d %H:%M"), "game_uid": str(game_service.game_id_counter) }) diff --git a/minikube-example.yaml b/minikube-example.yaml index 3fa64df19..2258f8242 100644 --- a/minikube-example.yaml +++ b/minikube-example.yaml @@ -51,6 +51,10 @@ spec: env: - name: CONFIGURATION_FILE value: /config/config.yaml + - name: CONTAINER_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name volumeMounts: - name: config mountPath: /config diff --git a/server/info.py b/server/info.py new file mode 100644 index 000000000..5c7767a11 --- /dev/null +++ b/server/info.py @@ -0,0 +1,12 @@ +""" +Static meta information about the container/process +""" + +import os +import platform + +PYTHON_VERSION = platform.python_version() + +# Environment variables +VERSION = os.getenv("VERSION") or "dev" +CONTAINER_NAME = os.getenv("CONTAINER_NAME") or "faf-python-server"