From 11eb57ed2f2249f513e7c85927d4dd885260c7ad Mon Sep 17 00:00:00 2001 From: Krateng Date: Fri, 6 Dec 2019 18:34:29 +0100 Subject: [PATCH] Added auto-update --- maloja/data_files/settings/default.ini | 1 + maloja/supervisor.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/maloja/data_files/settings/default.ini b/maloja/data_files/settings/default.ini index f232f06..b245bc7 100644 --- a/maloja/data_files/settings/default.ini +++ b/maloja/data_files/settings/default.ini @@ -58,3 +58,4 @@ NAME = None EXPERIMENTAL_FEATURES = no USE_PYHP = no FEDERATION = yes +UPDATE_AFTER_CRASH = no #update when server is automatically restarted diff --git a/maloja/supervisor.py b/maloja/supervisor.py index edf9291..5656858 100644 --- a/maloja/supervisor.py +++ b/maloja/supervisor.py @@ -1,10 +1,14 @@ #!/usr/bin/env python3 +import os +from .__init__ import DATA_DIR +os.chdir(DATA_DIR) import subprocess import time import setproctitle import signal from doreah.logging import log +from doreah.settings import get_settings setproctitle.setproctitle("maloja_supervisor") @@ -19,6 +23,12 @@ while True: log("Maloja is running, PID " + str(pid),module="supervisor") except: log("Maloja is not running, restarting...",module="supervisor") + if get_settings("UPDATE_AFTER_CRASH"): + log("Updating first...",module="supervisor") + try: + os.system("pip3 install maloja --upgrade --no-cache-dir") + except: + log("Could not update.",module="supervisor") try: p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) except e: