Compare commits
4 Commits
5ec57150b1
...
e1dc7bc5c9
Author | SHA1 | Date | |
---|---|---|---|
e1dc7bc5c9 | |||
ffd83d8bbc | |||
9ee391fee8 | |||
f7dfaafc59 |
22
.github/workflows/monolith.yml
vendored
22
.github/workflows/monolith.yml
vendored
@@ -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
|
|
@@ -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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
25
main.py
25
main.py
@@ -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,24 +180,20 @@ 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)
|
driver.get(url)
|
||||||
|
|
||||||
for attempt in range(retries):
|
try:
|
||||||
driver.get(url)
|
wait.until(ec.presence_of_element_located((By.CLASS_NAME, 'vjs-big-play-button')))
|
||||||
try:
|
except Exception:
|
||||||
wait.until(ec.presence_of_element_located((By.CLASS_NAME, 'vjs-big-play-button')))
|
logger.error('Timeout while waiting for the big play button to be present.')
|
||||||
break
|
driver.quit()
|
||||||
except Exception:
|
raise SystemExit(1)
|
||||||
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)
|
|
||||||
|
|
||||||
actions.click(driver.find_element(By.CLASS_NAME ,'video-js')).perform()
|
actions.click(driver.find_element(By.CLASS_NAME ,'video-js')).perform()
|
||||||
wait.until(ec.visibility_of_element_located((By.CLASS_NAME, 'vjs-control-bar')))
|
wait.until(ec.visibility_of_element_located((By.CLASS_NAME, 'vjs-control-bar')))
|
||||||
|
@@ -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
|
|
Reference in New Issue
Block a user