Skip to content

Commit

Permalink
Add info module for collecting static info
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Jul 9, 2023
1 parent 58f9867 commit d385ab8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
18 changes: 8 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import asyncio
import logging
import os
import platform
import signal
import sys
import time
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
})
Expand Down
4 changes: 4 additions & 0 deletions minikube-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions server/info.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit d385ab8

Please sign in to comment.