From 8a1a32727d9ad4234059aa19ca9810af9af33db1 Mon Sep 17 00:00:00 2001 From: sepehr Date: Thu, 2 Jan 2025 22:52:40 +0300 Subject: [PATCH] Fix update issues and wrong data, Fix updater for pro users get segmentation fault,need to kill main procces and reload --- migrations/024_sysconfig_update.py | 4 +++- py/mules/updater.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/migrations/024_sysconfig_update.py b/migrations/024_sysconfig_update.py index 694e290..19bef0b 100644 --- a/migrations/024_sysconfig_update.py +++ b/migrations/024_sysconfig_update.py @@ -2,4 +2,6 @@ def migrate(migrator, database, fake=False, **kwargs): - migrator.sql("""INSERT INTO public.sysconfig( key, value) VALUES ( 'update_mode', 'auto')""") + migrator.sql("""INSERT INTO public.sysconfig( key, value) VALUES ( 'update_mode', '{"mode": "manual", "update_back": false, "update_front": false}')""") + + diff --git a/py/mules/updater.py b/py/mules/updater.py index a1511c8..69733ad 100644 --- a/py/mules/updater.py +++ b/py/mules/updater.py @@ -17,6 +17,8 @@ import hashlib import zipfile import subprocess import json +import uwsgi +import signal log = logging.getLogger("Updater_mule") import pip @@ -68,7 +70,6 @@ def check_sha256(filename, expect): return False def extract_zip_reload(filename,dst): - return True """Extract the contents of the zip file "filename" to the directory "dst". Then reload the updated modules.""" with zipfile.ZipFile(filename, 'r') as zip_ref: @@ -100,6 +101,8 @@ def extract_zip_reload(filename,dst): pass os.remove(filename) #touch server reload file /app/reload + masterpid=uwsgi.masterpid() + os.kill(masterpid, signal.SIGKILL) Path('/app/reload').touch() def main(): @@ -117,7 +120,11 @@ def main(): interfaces = util.get_ethernet_wifi_interfaces() hwid = util.generate_serial_number(interfaces) update_mode=db_sysconfig.get_sysconfig('update_mode') - update_mode=json.loads(update_mode) + try: + update_mode=json.loads(update_mode) + except: + update_mode={'mode':'auto','update_back':False,'update_front':False} + db_sysconfig.set_sysconfig('update_mode',json.dumps(update_mode)) if update_mode['mode']=='manual': if not update_mode['update_back']: hwid=hwid+"MANUAL"