Redis pool limit / Systemd killmode / Devices plural

This commit is contained in:
Capybara-z
2026-04-20 22:35:46 +00:00
parent 68ea6db6c7
commit 88e947beb9
7 changed files with 18 additions and 11 deletions
+1
View File
@@ -27,6 +27,7 @@ redis = redis_from_url(
REDIS_URL,
encoding="utf-8",
decode_responses=True,
max_connections=64,
health_check_interval=30,
socket_connect_timeout=5,
socket_timeout=5,
+3 -1
View File
@@ -402,7 +402,9 @@ def build_systemd_service() -> str:
f"WorkingDirectory={PROJECT_DIR}\n"
f"ExecStart={VENV_PYTHON} {os.path.join(PROJECT_DIR, 'main.py')}\n"
"Restart=always\n"
"RestartSec=5\n"
"RestartSec=10\n"
"TimeoutStopSec=10\n"
"KillMode=control-group\n"
'Environment="PYTHONUNBUFFERED=1"\n\n'
"[Install]\n"
"WantedBy=multi-user.target\n"
+2 -2
View File
@@ -28,7 +28,7 @@ from handlers.texts import (
UNLIMITED_DEVICES_LABEL,
UNLIMITED_TRAFFIC_LABEL,
)
from handlers.utils import edit_or_send_message
from handlers.utils import edit_or_send_message, get_plural_form
from hooks.hook_buttons import insert_hook_buttons
from hooks.processors import process_addon_purchase_complete, process_addons_menu
from logger import logger
@@ -236,7 +236,7 @@ async def render_addons_screen(callback: CallbackQuery, state: FSMContext, sessi
if value == 0:
caption = f"{UNLIMITED_DEVICES_LABEL.capitalize()}{mark}"
else:
caption = f"{value} устройств{mark}"
caption = f"{value} {get_plural_form(value, 'устройство', 'устройства', 'устройств')}{mark}"
device_buttons.append(
InlineKeyboardButton(
text=caption,
+2 -2
View File
@@ -29,7 +29,7 @@ from handlers.texts import (
UNLIMITED_DEVICES_LABEL,
UNLIMITED_TRAFFIC_LABEL,
)
from handlers.utils import edit_or_send_message
from handlers.utils import edit_or_send_message, get_plural_form
from hooks.hook_buttons import insert_hook_buttons
from hooks.processors import process_addon_purchase_complete, process_addons_menu
from logger import logger
@@ -324,7 +324,7 @@ async def render_addons_screen(callback: CallbackQuery, state: FSMContext, sessi
if value == 0:
caption = f"{UNLIMITED_DEVICES_LABEL.capitalize()}{mark}"
else:
caption = f"{value} устройств{mark}"
caption = f"{value} {get_plural_form(value, 'устройство', 'устройства', 'устройств')}{mark}"
device_buttons.append(
InlineKeyboardButton(
text=caption,
+2 -1
View File
@@ -3,6 +3,7 @@ from typing import Any
from aiogram.fsm.state import State, StatesGroup
from handlers.utils import get_plural_form
from handlers.texts import (
ADDONS_CURRENT_HEADER_TEXT,
ADDONS_HINT_BOTH_OPTIONS_TEXT,
@@ -39,7 +40,7 @@ def format_devices_label(value, default_text: str = "по умолчанию") -
value_int = int(value)
if value_int <= 0:
return UNLIMITED_DEVICES_LABEL
return f"{value_int} устройств"
return f"{value_int} {get_plural_form(value_int, 'устройство', 'устройства', 'устройств')}"
def format_traffic_label(value, default_text: str = "по умолчанию") -> str:
+8 -5
View File
@@ -23,7 +23,7 @@ from handlers.texts import (
UNLIMITED_DEVICES_LABEL,
UNLIMITED_TRAFFIC_LABEL,
)
from handlers.utils import edit_or_send_message, safe_answer_callback
from handlers.utils import edit_or_send_message, get_plural_form, safe_answer_callback
from hooks.processors import process_check_discount_validity
from logger import logger
from services.payments.currency_rates import format_for_user
@@ -430,7 +430,8 @@ async def render_user_config_screen(
if int(base_device) <= 0:
base_devices_label = UNLIMITED_DEVICES_LABEL
else:
base_devices_label = f"{int(base_device)} устройств"
_bd = int(base_device)
base_devices_label = f"{_bd} {get_plural_form(_bd, 'устройство', 'устройства', 'устройств')}"
base_parts.append(base_devices_label)
if base_traffic_gb is not None:
@@ -454,7 +455,8 @@ async def render_user_config_screen(
if int(selected_devices) <= 0:
devices_label = UNLIMITED_DEVICES_LABEL
else:
devices_label = f"{int(selected_devices)} устройств"
_sd = int(selected_devices)
devices_label = f"{_sd} {get_plural_form(_sd, 'устройство', 'устройства', 'устройств')}"
choice_parts.append(devices_label)
if has_traffic_choice:
@@ -480,7 +482,8 @@ async def render_user_config_screen(
_rs_trf = data.get("renew_selected_traffic_limit")
_addon_parts: list[str] = []
if _rc_dev is not None and _rs_dev is not None and int(_rc_dev) > int(_rs_dev):
_addon_parts.append(f"+{int(_rc_dev) - int(_rs_dev)} устройств")
_diff_dev = int(_rc_dev) - int(_rs_dev)
_addon_parts.append(f"+{_diff_dev} {get_plural_form(_diff_dev, 'устройство', 'устройства', 'устройств')}")
if _rc_trf is not None and _rs_trf is not None and int(_rc_trf) > int(_rs_trf):
_addon_parts.append(f"+{int(_rc_trf) - int(_rs_trf)} ГБ")
if _addon_parts:
@@ -505,7 +508,7 @@ async def render_user_config_screen(
if value == 0:
caption = f"{UNLIMITED_DEVICES_LABEL.capitalize()}{mark}"
else:
caption = f"{value} устройств{mark}"
caption = f"{value} {get_plural_form(value, 'устройство', 'устройства', 'устройств')}{mark}"
device_buttons.append(
InlineKeyboardButton(
text=caption,
Regular → Executable
View File