Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyUltroid/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def main():
WasItRestart,
autopilot,
customize,
keep_redis_alive,
plug,
ready,
startup_stuff,
Expand Down Expand Up @@ -49,6 +50,7 @@ def main():
LOGS.info("Initialising...")

ultroid_bot.run_in_loop(autopilot())
ultroid_bot.loop.create_task(keep_redis_alive())

pmbot = udB.get_key("PMBOT")
manager = udB.get_key("MANAGER")
Expand Down
4 changes: 2 additions & 2 deletions pyUltroid/startup/_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ def __init__(
if platform.lower() == "qovery" and not host:
var, hash_, host, password = "", "", "", ""
for vars_ in os.environ:
if vars_.startswith("QOVERY_REDIS_") and vars.endswith("_HOST"):
if vars_.startswith("QOVERY_REDIS_") and vars_.endswith("_HOST"):
var = vars_
if var:
hash_ = var.split("_", maxsplit=2)[1].split("_")[0]
if hash:
if hash_:
kwargs["host"] = os.environ.get(f"QOVERY_REDIS_{hash_}_HOST")
kwargs["port"] = os.environ.get(f"QOVERY_REDIS_{hash_}_PORT")
kwargs["password"] = os.environ.get(f"QOVERY_REDIS_{hash_}_PASSWORD")
Expand Down
30 changes: 30 additions & 0 deletions pyUltroid/startup/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import random
import shutil
import time
from datetime import datetime, timezone as dt_timezone
from random import randint

from ..configs import Var
Expand Down Expand Up @@ -47,6 +48,8 @@
from ..fns.helper import download_file, inline_mention, updater

db_url = 0
REDIS_KEEPALIVE_KEY = "KEEP_ACTIVE"
REDIS_KEEPALIVE_INTERVAL_SECONDS = 7 * 24 * 60 * 60


async def autoupdate_local_database():
Expand Down Expand Up @@ -152,6 +155,33 @@ async def startup_stuff():
time.tzset()


async def keep_redis_alive():
from .. import udB

if udB.name != "Redis":
return

interval = udB.get_key("REDIS_KEEPALIVE_INTERVAL")
try:
interval = int(interval) if interval else REDIS_KEEPALIVE_INTERVAL_SECONDS
except (TypeError, ValueError):
interval = REDIS_KEEPALIVE_INTERVAL_SECONDS
interval = max(interval, 60)

while True:
try:
now = datetime.now(dt_timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
udB.set_key(REDIS_KEEPALIVE_KEY, f"Updated value at {now}")
LOGS.debug(
"Redis keepalive updated key '%s' (next run in %s seconds).",
REDIS_KEEPALIVE_KEY,
interval,
)
except Exception as exc:
LOGS.warning("Redis keepalive update failed: %s", exc)
await asyncio.sleep(interval)


async def autobot():
from .. import udB, ultroid_bot

Expand Down
4 changes: 2 additions & 2 deletions pyUltroid/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2025.05.31"
ultroid_version = "2.1.1"
__version__ = "2026.04.03"
ultroid_version = "2.1.2"
Loading