Fix update issues and wrong data, Fix updater for pro users get segmentation fault,need to kill main procces and reload

This commit is contained in:
sepehr 2025-01-02 22:52:40 +03:00
parent 70dc0ddc55
commit 8a1a32727d
2 changed files with 12 additions and 3 deletions

View file

@ -2,4 +2,6 @@
def migrate(migrator, database, fake=False, **kwargs): 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}')""")

View file

@ -17,6 +17,8 @@ import hashlib
import zipfile import zipfile
import subprocess import subprocess
import json import json
import uwsgi
import signal
log = logging.getLogger("Updater_mule") log = logging.getLogger("Updater_mule")
import pip import pip
@ -68,7 +70,6 @@ def check_sha256(filename, expect):
return False return False
def extract_zip_reload(filename,dst): def extract_zip_reload(filename,dst):
return True
"""Extract the contents of the zip file "filename" to the directory """Extract the contents of the zip file "filename" to the directory
"dst". Then reload the updated modules.""" "dst". Then reload the updated modules."""
with zipfile.ZipFile(filename, 'r') as zip_ref: with zipfile.ZipFile(filename, 'r') as zip_ref:
@ -100,6 +101,8 @@ def extract_zip_reload(filename,dst):
pass pass
os.remove(filename) os.remove(filename)
#touch server reload file /app/reload #touch server reload file /app/reload
masterpid=uwsgi.masterpid()
os.kill(masterpid, signal.SIGKILL)
Path('/app/reload').touch() Path('/app/reload').touch()
def main(): def main():
@ -117,7 +120,11 @@ def main():
interfaces = util.get_ethernet_wifi_interfaces() interfaces = util.get_ethernet_wifi_interfaces()
hwid = util.generate_serial_number(interfaces) hwid = util.generate_serial_number(interfaces)
update_mode=db_sysconfig.get_sysconfig('update_mode') 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 update_mode['mode']=='manual':
if not update_mode['update_back']: if not update_mode['update_back']:
hwid=hwid+"MANUAL" hwid=hwid+"MANUAL"