Skip to content

Commit

Permalink
ping with revision
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Feb 11, 2022
1 parent 9d2b532 commit 5133bd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions ytdlbot/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,22 @@ def get_receive_link_text():

@staticmethod
def ping_worker():
from tasks import app as celery_app
workers = InfluxDB().extract_dashboard_data()
# [{'celery@BennyのMBP': 'abc'}, {'celery@BennyのMBP': 'abc'}]
response = celery_app.control.broadcast("ping_revision", reply=True)
revision = {}
for item in response:
revision.update(item)

text = ""
for worker in workers:
fields = worker["fields"]
hostname = worker["tags"]["hostname"]
status = {True: "✅"}.get(fields["status"], "❌")
active = fields["active"]
load = "{},{},{}".format(fields["load1"], fields["load5"], fields["load15"])
text += f"{status}{hostname} **{active}** {load}\n"
return text
rev = revision.get(hostname, "")
text += f"{status}{hostname} **{active}** {load} {rev}\n"

return text
7 changes: 6 additions & 1 deletion ytdlbot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
ytdl_download)
from limit import VIP
from utils import (apply_log_formatter, auto_restart, customize_logger,
get_metadata, get_user_settings)
get_metadata, get_revision, get_user_settings)

customize_logger(["pyrogram.client", "pyrogram.session.session", "pyrogram.connection.connection"])
apply_log_formatter()
Expand Down Expand Up @@ -321,6 +321,11 @@ def ytdl_normal_download(bot_msg, client, url):
temp_dir.cleanup()


@Panel.register
def ping_revision(*args):
return get_revision()


@Panel.register
def hot_patch(*args):
app_path = pathlib.Path().cwd().parent
Expand Down

0 comments on commit 5133bd6

Please sign in to comment.