mirror of
https://github.com/omg-xtao/ytdlbot.git
synced 2025-01-30 09:48:35 +00:00
fix hot patch
This commit is contained in:
parent
a3a821bfae
commit
9d2b532d21
@ -9,10 +9,11 @@ FROM python:3.9-alpine
|
||||
WORKDIR /ytdlbot/ytdlbot
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
RUN apk update && apk add --no-cache ffmpeg vnstat git
|
||||
COPY apk.txt /tmp/
|
||||
RUN apk update && xargs apk add < /tmp/apk.txt
|
||||
COPY --from=builder /root/.local /usr/local
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY . /ytdlbot
|
||||
|
||||
CMD ["/usr/local/bin/supervisord", "-c" ,"/ytdlbot/conf/supervisor_main.conf"]
|
||||
CMD ["/usr/local/bin/supervisord", "-c" ,"/ytdlbot/conf/supervisor_main.conf"]
|
||||
|
@ -323,21 +323,23 @@ def ytdl_normal_download(bot_msg, client, url):
|
||||
|
||||
@Panel.register
|
||||
def hot_patch(*args):
|
||||
git_path = pathlib.Path().cwd().parent
|
||||
logging.info("Hot patching on path %s...", git_path)
|
||||
app_path = pathlib.Path().cwd().parent
|
||||
logging.info("Hot patching on path %s...", app_path)
|
||||
|
||||
apk_install = "xargs apk add < apk.txt"
|
||||
pip_install = "pip install -r requirements.txt"
|
||||
unset = "git config --unset http.https://github.com/.extraheader"
|
||||
pull_unshallow = "git pull origin --unshallow"
|
||||
pull = "git pull"
|
||||
|
||||
subprocess.call(pip_install, shell=True, cwd=git_path)
|
||||
subprocess.call(unset, shell=True, cwd=git_path)
|
||||
if subprocess.call(pull_unshallow, shell=True, cwd=git_path) != 0:
|
||||
subprocess.check_output(unset, shell=True, cwd=app_path)
|
||||
if subprocess.check_output(pull_unshallow, shell=True, cwd=app_path) != 0:
|
||||
logging.info("Already unshallow, pulling now...")
|
||||
subprocess.call(pull, shell=True, cwd=git_path)
|
||||
subprocess.check_output(pull, shell=True, cwd=app_path)
|
||||
|
||||
logging.info("Code is updated, applying hot patch now...")
|
||||
subprocess.check_output(apk_install, shell=True, cwd=app_path)
|
||||
subprocess.check_output(pip_install, shell=True, cwd=app_path)
|
||||
psutil.Process().kill()
|
||||
|
||||
|
||||
|
@ -138,8 +138,8 @@ def patch_handler(client: "Client", message: "types.Message"):
|
||||
if username == OWNER:
|
||||
celery_app.control.broadcast("hot_patch")
|
||||
client.send_chat_action(chat_id, "typing")
|
||||
hot_patch()
|
||||
client.send_message(chat_id, "Oorah!")
|
||||
hot_patch()
|
||||
|
||||
|
||||
@app.on_message(filters.command(["ping"]))
|
||||
|
Loading…
Reference in New Issue
Block a user