Compare commits

..

4 Commits

Author SHA1 Message Date
e1dc7bc5c9 feat: update README and main.py to clarify port usage and add error handling for socket port
All checks were successful
Build Docker Images for Pull Request / build (pull_request) Successful in 17m5s
2025-02-20 23:55:46 +01:00
ffd83d8bbc feat: add environment variable documentation and update configurations for socket port in Docker setup
All checks were successful
Build Docker Images for Pull Request / build (pull_request) Successful in 15m3s
2025-02-20 22:48:25 +01:00
9ee391fee8 feat: streamline Dockerfile and docker-compose configuration for improved build efficiency
All checks were successful
Build Docker Images for Pull Request / build (pull_request) Successful in 16m45s
2025-02-20 21:13:02 +01:00
f7dfaafc59 feat: add convenience functions, update Docker setup, and integrate Webpack for building WebRTC internals exporter
All checks were successful
Build Docker Images for Pull Request / build (pull_request) Successful in 15m15s
2025-02-20 11:37:37 +01:00
4 changed files with 17 additions and 46 deletions

View File

@@ -7,7 +7,6 @@ on:
env: env:
REGISTRY_URL: gitea.kobim.cloud REGISTRY_URL: gitea.kobim.cloud
DOCKERHUB_USERNAME: kobimex
jobs: jobs:
build: build:
@@ -19,14 +18,14 @@ jobs:
- name: Setup Docker Environment - name: Setup Docker Environment
uses: ./.github/actions/setup-docker-environment uses: ./.github/actions/setup-docker-environment
- name: Log in to custom Docker registry - name: Log in to Docker registry
uses: docker/login-action@v3.3.0 uses: docker/login-action@v3.3.0
with: with:
registry: ${{ env.REGISTRY_URL }} registry: ${{ env.REGISTRY_URL }}
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push Docker image to custom registry - name: Build and push Docker image
uses: docker/build-push-action@v6.13.0 uses: docker/build-push-action@v6.13.0
with: with:
context: . context: .
@@ -36,20 +35,3 @@ jobs:
platforms: | platforms: |
linux/amd64 linux/amd64
linux/arm64 linux/arm64
- name: Log in to Docker Hub
uses: docker/login-action@v3.3.0
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image to Docker Hub
uses: docker/build-push-action@v6.13.0
with:
context: .
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}-monolith:latest
file: ./Monolith.dockerfile
platforms: |
linux/amd64
linux/arm64

View File

@@ -59,13 +59,7 @@ To stop the Docker containers run: `docker compose down -v`
3. Ajust the firewall settings to allow the necessary ports if needed 3. Ajust the firewall settings to allow the necessary ports if needed
4. Start the Docker container: 4. Start the Docker container:
```sh ```sh
docker run --rm -p 7900:7900 --env-file .env --name peertube-collector --pull always --shm-size="2g" gitea.kobim.cloud/kobim/peertube-collector-monolith:latest docker run --rm -p 7900:7900 --env-file .env --name peertube-collector gitea.kobim.cloud/kobim/peertube-collector-monolith:latest
```
or
```sh
docker run --rm -p 7900:7900 --env-file .env --name peertube-collector --pull always --shm-size="2g" kobimex/peertube-collector-monolith:latest
``` ```

15
main.py
View File

@@ -5,7 +5,7 @@ import socket
import logging import logging
import os import os
import argparse import argparse
from time import sleep from yaspin import yaspin
from functools import partial from functools import partial
from http.server import HTTPServer from http.server import HTTPServer
from utils.PostHandler import Handler from utils.PostHandler import Handler
@@ -50,6 +50,7 @@ def interrupt_handler(signum, driver: webdriver.Remote):
driver.quit() driver.quit()
raise SystemExit raise SystemExit
@yaspin()
def setupChromeDriver(command_executor: str | None, webrtc_internals_path: str) -> webdriver.Remote | webdriver.Chrome: def setupChromeDriver(command_executor: str | None, webrtc_internals_path: str) -> webdriver.Remote | webdriver.Chrome:
logger.log(logging.INFO, 'Setting up Chrome driver.') logger.log(logging.INFO, 'Setting up Chrome driver.')
chrome_options = Options() chrome_options = Options()
@@ -179,22 +180,18 @@ def downloadStats(driver: webdriver.Remote | webdriver.Chrome, peersDict: dict,
def convert_to_bytes(down, downUnit): def convert_to_bytes(down, downUnit):
return float(down) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[downUnit]) return float(down) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[downUnit])
def setupStats(driver: webdriver.Remote, url: str, retries: int = 5) -> webdriver.Remote: @yaspin()
def setupStats(driver: webdriver.Remote, url: str):
logger.log(logging.INFO, 'Setting up stats.') logger.log(logging.INFO, 'Setting up stats.')
actions = ActionChains(driver) actions = ActionChains(driver)
wait = WebDriverWait(driver, 30, poll_frequency=0.2) wait = WebDriverWait(driver, 30, poll_frequency=0.2)
sleep(2)
for attempt in range(retries):
driver.get(url) driver.get(url)
try: try:
wait.until(ec.presence_of_element_located((By.CLASS_NAME, 'vjs-big-play-button'))) wait.until(ec.presence_of_element_located((By.CLASS_NAME, 'vjs-big-play-button')))
break
except Exception: except Exception:
logger.error(f'Timeout while waiting for the big play button to be present. Attempt {attempt + 1} of {retries}') logger.error('Timeout while waiting for the big play button to be present.')
if attempt == retries - 1:
logger.error('Timeout limit reached. Exiting.')
driver.quit() driver.quit()
raise SystemExit(1) raise SystemExit(1)

View File

@@ -48,8 +48,6 @@ done
printf '\n' printf '\n'
# Start the Telegraf agent # Start the Telegraf agent and the main script
telegraf --config ./telegraf.conf & telegraf --config ./telegraf.conf &
./venv/bin/python main.py
# Start the main Python script as PID 1
exec ./venv/bin/python main.py