From 00a3fbae211d0f5f1faee62a5aadd0b74aa42980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 1 Jun 2024 09:56:18 +0200 Subject: [PATCH] Move readme generator webhook service to its own directory --- readme_generator/webhook.service | 16 ---------------- {readme_generator => webhooks}/webhook.py | 6 +++++- webhooks/webhook.service | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 17 deletions(-) delete mode 100644 readme_generator/webhook.service rename {readme_generator => webhooks}/webhook.py (94%) create mode 100644 webhooks/webhook.service diff --git a/readme_generator/webhook.service b/readme_generator/webhook.service deleted file mode 100644 index e4783c7..0000000 --- a/readme_generator/webhook.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Auto-README webhook gunicorn daemon -After=network.target - -[Service] -PIDFile=/run/gunicorn/autoreadme_webhook-pid -User=autoreadme_webhook -Group=autoreadme_webhook -WorkingDirectory=__PATH_TO_README_GENERATOR__ -ExecStart=__PATH_TO_README_GENERATOR__/venv/bin/gunicorn -w 4 -b 127.0.0.1:8123 webhook:app -ExecReload=/bin/kill -s HUP $MAINPID -ExecStop=/bin/kill -s TERM $MAINPID -PrivateTmp=true - -[Install] -WantedBy=multi-user.target diff --git a/readme_generator/webhook.py b/webhooks/webhook.py similarity index 94% rename from readme_generator/webhook.py rename to webhooks/webhook.py index 3e66875..08950e1 100755 --- a/readme_generator/webhook.py +++ b/webhooks/webhook.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import sys import hashlib import hmac from functools import cache @@ -9,7 +10,10 @@ from pathlib import Path from git import Actor, Repo from sanic import HTTPResponse, Request, Sanic, response -from make_readme import generate_READMEs +# add apps/tools to sys.path +sys.path.insert(0, str(Path(__file__).parent.parent)) + +from readme_generator.make_readme import generate_READMEs TOOLS_DIR = Path(__file__).resolve().parent.parent diff --git a/webhooks/webhook.service b/webhooks/webhook.service new file mode 100644 index 0000000..a15bbf6 --- /dev/null +++ b/webhooks/webhook.service @@ -0,0 +1,16 @@ +[Unit] +Description=Auto-README webhook gunicorn daemon +After=network.target + +[Service] +PIDFile=/run/gunicorn/apps_webhooks-pid +User=apps_webhooks +Group=apps_webhooks +WorkingDirectory=__PATH_TO_APPS_TOOLS__/webhooks +ExecStart=__PATH_TO_APPS_TOOLS__/webhooks/venv/bin/gunicorn -w 4 -b 127.0.0.1:8123 webhook:app +ExecReload=/bin/kill -s HUP $MAINPID +ExecStop=/bin/kill -s TERM $MAINPID +PrivateTmp=true + +[Install] +WantedBy=multi-user.target