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:
REGISTRY_URL: gitea.kobim.cloud
DOCKERHUB_USERNAME: kobimex
jobs:
build:
@@ -19,37 +18,20 @@ jobs:
- name: 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
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ github.actor }}
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
with:
context: .
push: true
tags: ${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ github.event.repository.name }}-monolith:latest
file: ./Monolith.dockerfile
platforms: |
linux/amd64
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
4. Start the Docker container:
```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
```
or
```sh
docker run --rm -p 7900:7900 --env-file .env --name peertube-collector --pull always --shm-size="2g" kobimex/peertube-collector-monolith:latest
docker run --rm -p 7900:7900 --env-file .env --name peertube-collector gitea.kobim.cloud/kobim/peertube-collector-monolith:latest
```

27
main.py
View File

@@ -5,7 +5,7 @@ import socket
import logging
import os
import argparse
from time import sleep
from yaspin import yaspin
from functools import partial
from http.server import HTTPServer
from utils.PostHandler import Handler
@@ -50,6 +50,7 @@ def interrupt_handler(signum, driver: webdriver.Remote):
driver.quit()
raise SystemExit
@yaspin()
def setupChromeDriver(command_executor: str | None, webrtc_internals_path: str) -> webdriver.Remote | webdriver.Chrome:
logger.log(logging.INFO, 'Setting up Chrome driver.')
chrome_options = Options()
@@ -179,24 +180,20 @@ def downloadStats(driver: webdriver.Remote | webdriver.Chrome, peersDict: dict,
def convert_to_bytes(down, 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.')
actions = ActionChains(driver)
wait = WebDriverWait(driver, 30, poll_frequency=0.2)
sleep(2)
for attempt in range(retries):
driver.get(url)
try:
wait.until(ec.presence_of_element_located((By.CLASS_NAME, 'vjs-big-play-button')))
break
except Exception:
logger.error(f'Timeout while waiting for the big play button to be present. Attempt {attempt + 1} of {retries}')
if attempt == retries - 1:
logger.error('Timeout limit reached. Exiting.')
driver.quit()
raise SystemExit(1)
driver.get(url)
try:
wait.until(ec.presence_of_element_located((By.CLASS_NAME, 'vjs-big-play-button')))
except Exception:
logger.error('Timeout while waiting for the big play button to be present.')
driver.quit()
raise SystemExit(1)
actions.click(driver.find_element(By.CLASS_NAME ,'video-js')).perform()
wait.until(ec.visibility_of_element_located((By.CLASS_NAME, 'vjs-control-bar')))

View File

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