Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

336 experimental log analyzer #336

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ CHANNEL_REDIS=True

POSTGRES_DB=dps
POSTGRES_USER=dps
POSTGRES_PASSWORD=dps
POSTGRES_PASSWORD=dps
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ backend/.vscode/settings.json
.idea/
.vscode/launch.json
backend/dps_training_k/restart_backend.sh
backend/dps_training_k/game/migrations/0008_remove_logentry_message_logentry_content_and_more.py
_build/.filesystem-clock
_build/.lock
_build/log
backend/dps_training_k/game/templmon/log_rules/*.mfotl
backend/dps_training_k/game/templmon/signature_test.sig
2 changes: 2 additions & 0 deletions backend/dps_training_k/.env.process_beat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROCESS_ID=2
PARTNER_PROCESS_ID=-1
2 changes: 2 additions & 0 deletions backend/dps_training_k/.env.process_django
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROCESS_ID=0
PARTNER_PROCESS_ID=1
2 changes: 2 additions & 0 deletions backend/dps_training_k/.env.process_worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROCESS_ID=1
PARTNER_PROCESS_ID=0
28 changes: 26 additions & 2 deletions backend/dps_training_k/deployment/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ARG PYTHON_VERSION=3.12-slim-bullseye

# define an alias for the specfic python version used in this file.
FROM python:${PYTHON_VERSION} as python
FROM python:${PYTHON_VERSION} AS python

# Python 'run' stage
FROM python as python-run-stage
FROM python AS python-run-stage

ARG APP_HOME=/app

Expand All @@ -21,10 +21,34 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
libpq-dev gcc python3-dev musl-dev \
# Translations dependencies
gettext \
# OCaml and MonPoly dependencies
git opam \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*

# Initialize OPAM and switch to the required OCaml version
RUN opam init -y --disable-sandboxing && \
opam switch create 4.11.1 && \
eval $(opam env) && \
opam install dune -y

# Clone the MonPoly repository
RUN git clone https://bitbucket.org/monpoly/monpoly.git /home/opam/monpoly

# Set the working directory
WORKDIR /home/opam/monpoly

# Install dependencies
RUN eval $(opam env) && opam install --deps-only -y .

# Build and install MonPoly
RUN eval $(opam env) && dune build --release && dune install
ENV PATH="/root/.opam/4.11.1/bin:${PATH}"
# Verify MonPoly installation and PATH
RUN eval $(opam env) &&which monpoly && echo $PATH

WORKDIR ${APP_HOME}
# Install requirements
RUN pip install -r requirements.txt

Expand Down
28 changes: 28 additions & 0 deletions backend/dps_training_k/deployment/monpoly/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use an official OCaml base image
FROM ocaml/opam:debian-10-ocaml-4.11

# Install necessary packages
RUN sudo apt-get update && sudo apt-get install -y \
git \
opam

# Initialize OPAM and switch to the required OCaml version
RUN opam init -y --disable-sandboxing && \
opam switch create 4.11.1 && \
eval $(opam env)

# Clone the MonPoly repository
RUN git clone https://bitbucket.org/monpoly/monpoly.git

# Set the working directory
WORKDIR /home/opam/monpoly

# Install dependencies
RUN opam install --deps-only -y .

# Build and install MonPoly
RUN dune build --release && \
dune install

# Set the entrypoint to monpoly
ENTRYPOINT ["monpoly"]
3 changes: 3 additions & 0 deletions backend/dps_training_k/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
- redis
env_file:
- .env.${RUN_CONFIG}
- .env.process_django
environment:
- RUN_MIGRATIONS=1 # only django should run migrations
volumes:
Expand All @@ -57,6 +58,7 @@ services:
container_name: K-dPS-celeryworker
env_file:
- .env.${RUN_CONFIG}
- .env.process_worker
command: /start-celeryworker
depends_on:
- django
Expand All @@ -70,6 +72,7 @@ services:
container_name: K-dPS-celerybeat
env_file:
- .env.${RUN_CONFIG}
- .env.process_beat
command: /start-celerybeat
depends_on:
- django
Expand Down
19 changes: 17 additions & 2 deletions backend/dps_training_k/game/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,20 @@


class GameConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'game'
default_auto_field = "django.db.models.BigAutoField"
name = "game"

def ready(self):
import os

process_id = int(os.environ.get("PROCESS_ID", "0"))
# Only register listener if this is the django process (PROCESS_ID equals 0)
if process_id != 0:
return

# Import and register the listener function
from .channel_notifications import redis_publish_obj
from .redis_comm import start_listener_in_thread

start_listener_in_thread(redis_publish_obj)
print("Django listener thread started.")
Loading
Loading