diff --git a/Dockerfile b/Dockerfile index 03f6690..cc89c74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN set -ex \ && deps=' \ htop \ ' \ - && apt-get install -y python3 pip $buildDeps $deps --no-install-recommends && pip install -r /reqs.txt --break-system-packages + && apt-get install -y python3 python3-dev pip $buildDeps $deps --no-install-recommends && pip install -r /reqs.txt --break-system-packages COPY front-update.py / COPY mwcrontab /etc/cron.d/mwcrontab RUN chmod 0644 /etc/cron.d/mwcrontab diff --git a/front-update.py b/front-update.py index f632379..4fb35dd 100644 --- a/front-update.py +++ b/front-update.py @@ -15,8 +15,12 @@ import zipfile import subprocess import json from cryptography.fernet import Fernet +import psutil +import sys logging.basicConfig(level=logging.INFO) + + log = logging.getLogger("updater") log.setLevel(logging.INFO) API_URL="http://host.docker.internal:8181" @@ -116,6 +120,13 @@ def get_version_from_file(): def main(): while True: + pcount=0 + for process in psutil.process_iter(): + if '/front-update.py' in process.cmdline(): + pcount=pcount+1 + if pcount>=2: + print("Already running") + exit() try: next_hour = (time.time() // 3600 + 1) * 3600 sleep_time = next_hour - time.time() diff --git a/reqs.txt b/reqs.txt index f741b6c..cf38a08 100644 --- a/reqs.txt +++ b/reqs.txt @@ -1,2 +1,3 @@ cryptography==3.4.8 -Requests==2.32.2 \ No newline at end of file +Requests==2.32.2 +psutil==5.9.0 \ No newline at end of file