gitscope
← marzneshin / Diff · 9be9bfb → 9be9bfb
Changes 9be9bfb..9be9bfb
Patch commit
diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml
index 5109c8b..f10e5ff 100644
--- a/.github/workflows/package.yml
+++ b/.github/workflows/package.yml
@@ -17,6 +17,7 @@ on:
description: "Release Git Ref (Which branch or tag to build?)"
required: true
default: "master"
+
is-draft:
description: 'Draft Release? (Beta only, Nightly will always be a non-draft)'
type: boolean
@@ -40,6 +41,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
+ ref: ${{ github.event.inputs.git-ref }}
- uses: pnpm/action-setup@v4
name: Install pnpm
@@ -57,7 +59,7 @@ jobs:
working-directory: ./dashboard/
- name: Build Dashboard
- run: npm run build --if-present -- --outDir 'dist' --assetsDir 'static'
+ run: npm run build --if-present -- --outDir 'dist' --assetsDir 'static'
working-directory: ./dashboard/
- name: Set up QEMU
diff --git a/Dockerfile b/Dockerfile
index e9511cd..ece75b4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:3.11-slim
+FROM python:3.12-slim
ENV PYTHONUNBUFFERED 1
@@ -6,11 +6,6 @@ WORKDIR /app
COPY . /app
-RUN apt-get update -y \
- && apt-get install make git gcc g++ python3-dev -y --no-install-recommends \
- && pip install --no-cache-dir -r /app/requirements.txt \
- && apt-get clean -y \
- && apt-get remove g++ gcc python3-dev -y \
- && rm -rf /var/lib/apt/lists/*
+RUN pip install --no-cache-dir -r /app/requirements.txt
-CMD ["make", "start"]
+CMD ["sh", "-c", "alembic upgrade head && python3 main.py"]
diff --git a/app/marzneshin.py b/app/marzneshin.py
index 5552947..82c07d0 100644
--- a/app/marzneshin.py
+++ b/app/marzneshin.py
@@ -33,7 +33,6 @@ from .routes import api_router
from .tasks import (
delete_expired_reminders,
nodes_startup,
- record_realtime_bandwidth,
record_user_usages,
reset_user_data_usage,
review_users,
@@ -84,13 +83,6 @@ scheduler.add_job(
review_users, "interval", seconds=30, coalesce=True, max_instances=1
)
scheduler.add_job(reset_user_data_usage, "interval", coalesce=True, hours=1)
-scheduler.add_job(
- record_realtime_bandwidth,
- "interval",
- seconds=1,
- coalesce=True,
- max_instances=1,
-)
if WEBHOOK_ADDRESS:
scheduler.add_job(
diff --git a/app/tasks/__init__.py b/app/tasks/__init__.py
index 7d1e3d0..e2f2be1 100644
--- a/app/tasks/__init__.py
+++ b/app/tasks/__init__.py
@@ -1,10 +1,8 @@
-import logging
from .nodes import nodes_startup
from .record_usages import record_user_usages
from .reset_user_data_usage import reset_user_data_usage
from .review_users import review_users
from .send_notifications import delete_expired_reminders, send_notifications
-from .store_bandwidth import record_realtime_bandwidth
__all__ = [
"nodes_startup",
@@ -13,6 +11,4 @@ __all__ = [
"review_users",
"delete_expired_reminders",
"send_notifications",
- "store_bandwidth",
- "record_realtime_bandwidth",
]
diff --git a/app/tasks/store_bandwidth.py b/app/tasks/store_bandwidth.py
deleted file mode 100644
index efaedd4..0000000
--- a/app/tasks/store_bandwidth.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import psutil
-
-from app.utils.system import rt_bw
-
-
-def record_realtime_bandwidth() -> None:
- io = psutil.net_io_counters()
- rt_bw.incoming_bytes, rt_bw.bytes_recv = (
- io.bytes_recv - rt_bw.bytes_recv,
- io.bytes_recv,
- )
- rt_bw.outgoing_bytes, rt_bw.bytes_sent = (
- io.bytes_sent - rt_bw.bytes_sent,
- io.bytes_sent,
- )
- rt_bw.incoming_packets, rt_bw.packets_recv = (
- io.packets_recv - rt_bw.packets_recv,
- io.packets_recv,
- )
- rt_bw.outgoing_packets, rt_bw.packet_sent = (
- io.packets_sent - rt_bw.packet_sent,
- io.packets_sent,
- )
diff --git a/app/utils/system.py b/app/utils/system.py
index 0e97f0d..ebf86c4 100644
--- a/app/utils/system.py
+++ b/app/utils/system.py
@@ -1,88 +1,5 @@
import math
-import secrets
import socket
-from dataclasses import dataclass
-
-import psutil
-
-
-@dataclass
-class MemoryStat:
- total: int
- used: int
- free: int
-
-
-@dataclass
-class CPUStat:
- cores: int
- percent: float
-
-
-def cpu_usage() -> CPUStat:
- return CPUStat(cores=psutil.cpu_count(), percent=psutil.cpu_percent())
-
-
-def memory_usage() -> MemoryStat:
- mem = psutil.virtual_memory()
- return MemoryStat(total=mem.total, used=mem.used, free=mem.available)
-
-
-@dataclass
-class RealtimeBandwidth:
- def __post_init__(self):
- io = psutil.net_io_counters()
- self.bytes_recv = io.bytes_recv
- self.bytes_sent = io.bytes_sent
- self.packets_recv = io.packets_recv
- self.packet_sent = io.packets_sent
-
- incoming_bytes: int
- outgoing_bytes: int
- incoming_packets: int
- outgoing_packets: int
-
- bytes_recv: int = None
- bytes_sent: int = None
- packets_recv: int = None
- packet_sent: int = None
-
-
-@dataclass
-class RealtimeBandwidthStat:
- incoming_bytes: int
- outgoing_bytes: int
- incoming_packets: int
- outgoing_packets: int
-
-
-rt_bw = RealtimeBandwidth(
- incoming_bytes=0, outgoing_bytes=0, incoming_packets=0, outgoing_packets=0
-)
-
-
-def realtime_bandwidth() -> RealtimeBandwidthStat:
- return RealtimeBandwidthStat(
- incoming_bytes=rt_bw.incoming_bytes,
- outgoing_bytes=rt_bw.outgoing_bytes,
- incoming_packets=rt_bw.incoming_packets,
- outgoing_packets=rt_bw.outgoing_packets,
- )
-
-
-def random_password() -> str:
- return secrets.token_urlsafe(16)
-
-
-def check_port(port: int) -> bool:
- s = socket.socket()
- try:
- s.connect(("127.0.0.1", port))
- return True
- except socket.error:
- return False
- finally:
- s.close()
def get_public_ip():