From 8a468a46c27f67ce7b635b9e7491f91e9c2edda0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 2 Jun 2023 11:52:14 +0200 Subject: [PATCH] Continued: - need to check 'peer' if type 'None' - 48 hours is enough for checking for new instances, so fast no new instance will be created - updating 'last_updated' now moved to update_nodeinfos() --- config.defaults.json | 2 +- fba.py | 5 +---- fetch_instances.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/config.defaults.json b/config.defaults.json index 59d37ae..e9843bd 100644 --- a/config.defaults.json +++ b/config.defaults.json @@ -11,7 +11,7 @@ "bot_token" : "", "bot_visibility" : "unlisted", "slogan" : "### Your footer slogan ###", - "recheck_instance" : 43200, + "recheck_instance" : 172800, "recheck_block" : 43200, "misskey_offset" : 100, "error_log_cleanup" : 604800 diff --git a/fba.py b/fba.py index 7a738d8..2638800 100644 --- a/fba.py +++ b/fba.py @@ -350,7 +350,6 @@ def update_last_blocked(domain: str): # DEBUG: print("DEBUG: Updating last_blocked for domain", domain) nodeinfos["last_blocked"] = time.time() - nodeinfos["last_updated"] = time.time() # Running pending updated # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...") @@ -393,7 +392,7 @@ def update_nodeinfos(domain: str): raise ValueError(f"WARNING: No fields have been set, but method invoked, domain='{domain}'") # DEBUG: print(f"DEBUG: sql_string='{sql_string}',fields()={len(fields)}") - sql = "UPDATE instances SET" + sql_string + " last_status_code = NULL, last_error_details = NULL WHERE domain = ? LIMIT 1" + sql = "UPDATE instances SET" + sql_string + " last_status_code = NULL, last_error_details = NULL, last_updated = TIME() WHERE domain = ? LIMIT 1" # DEBUG: print("DEBUG: sql:", sql) try: @@ -464,7 +463,6 @@ def update_last_error(domain: str, res: any): res = str(res) # DEBUG: print("DEBUG: AFTER res[]:", type(res)) - nodeinfos["last_updated"][domain] = time.time() if type(res) is str: # DEBUG: print(f"DEBUG: Setting last_error_details='{res}'"); nodeinfos["last_status_code"][domain] = 999 @@ -488,7 +486,6 @@ def update_last_instance_fetch(domain: str): # DEBUG: print("DEBUG: Updating last_instance_fetch for domain:", domain) nodeinfos["last_instance_fetch"][domain] = time.time() - nodeinfos["last_updated"][domain] = time.time() # Running pending updated # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...") diff --git a/fetch_instances.py b/fetch_instances.py index fd217ef..3ff4918 100755 --- a/fetch_instances.py +++ b/fetch_instances.py @@ -42,7 +42,7 @@ def fetch_instances(domain: str, origin: str, software: str, path: str = None): print(f"INFO: Checking {len(peerlist)} instances from {domain} ...") for instance in peerlist: - if peerlist == None: + if instance == None: # Skip "None" types as tidup() cannot parse them continue -- 2.39.5