mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-23 06:00:18 +00:00
Added cache job scheduler
This commit is contained in:
parent
532f9ee665
commit
fc4c7638a6
@ -127,6 +127,7 @@ class Reticulum:
|
|||||||
MDU = MTU - HEADER_MAXSIZE - IFAC_MIN_SIZE
|
MDU = MTU - HEADER_MAXSIZE - IFAC_MIN_SIZE
|
||||||
|
|
||||||
CACHE_TIME = 24*60*60
|
CACHE_TIME = 24*60*60
|
||||||
|
JOB_INTERVAL = 300
|
||||||
|
|
||||||
router = None
|
router = None
|
||||||
config = None
|
config = None
|
||||||
@ -145,12 +146,6 @@ class Reticulum:
|
|||||||
# classes, saving necessary information to disk and carrying
|
# classes, saving necessary information to disk and carrying
|
||||||
# out cleanup operations.
|
# out cleanup operations.
|
||||||
|
|
||||||
if RNS.Transport.owner.share_instance:
|
|
||||||
if RNS.Transport.owner.is_shared_instance:
|
|
||||||
RNS.Transport.owner.__clean_caches()
|
|
||||||
else:
|
|
||||||
RNS.Transport.owner.__clean_caches()
|
|
||||||
|
|
||||||
RNS.Transport.exit_handler()
|
RNS.Transport.exit_handler()
|
||||||
RNS.Identity.exit_handler()
|
RNS.Identity.exit_handler()
|
||||||
|
|
||||||
@ -210,6 +205,7 @@ class Reticulum:
|
|||||||
self.is_shared_instance = False
|
self.is_shared_instance = False
|
||||||
self.is_connected_to_shared_instance = False
|
self.is_connected_to_shared_instance = False
|
||||||
self.is_standalone_instance = False
|
self.is_standalone_instance = False
|
||||||
|
self.jobs_thread = None
|
||||||
|
|
||||||
if not os.path.isdir(Reticulum.storagepath):
|
if not os.path.isdir(Reticulum.storagepath):
|
||||||
os.makedirs(Reticulum.storagepath)
|
os.makedirs(Reticulum.storagepath)
|
||||||
@ -257,6 +253,19 @@ class Reticulum:
|
|||||||
signal.signal(signal.SIGINT, Reticulum.sigint_handler)
|
signal.signal(signal.SIGINT, Reticulum.sigint_handler)
|
||||||
signal.signal(signal.SIGTERM, Reticulum.sigterm_handler)
|
signal.signal(signal.SIGTERM, Reticulum.sigterm_handler)
|
||||||
|
|
||||||
|
def __start_jobs(self):
|
||||||
|
if self.jobs_thread == None:
|
||||||
|
self.jobs_thread = threading.Thread(target=self.__jobs)
|
||||||
|
self.jobs_thread.setDaemon(True)
|
||||||
|
self.jobs_thread.start()
|
||||||
|
|
||||||
|
def __jobs(self):
|
||||||
|
while True:
|
||||||
|
# Clean caches
|
||||||
|
self.__clean_caches()
|
||||||
|
|
||||||
|
time.sleep(Reticulum.JOB_INTERVAL)
|
||||||
|
|
||||||
def __start_local_interface(self):
|
def __start_local_interface(self):
|
||||||
if self.share_instance:
|
if self.share_instance:
|
||||||
try:
|
try:
|
||||||
@ -269,7 +278,7 @@ class Reticulum:
|
|||||||
|
|
||||||
self.is_shared_instance = True
|
self.is_shared_instance = True
|
||||||
RNS.log("Started shared instance interface: "+str(interface), RNS.LOG_DEBUG)
|
RNS.log("Started shared instance interface: "+str(interface), RNS.LOG_DEBUG)
|
||||||
self.__clean_caches()
|
self.__start_jobs()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
@ -295,7 +304,7 @@ class Reticulum:
|
|||||||
self.is_shared_instance = False
|
self.is_shared_instance = False
|
||||||
self.is_standalone_instance = True
|
self.is_standalone_instance = True
|
||||||
self.is_connected_to_shared_instance = False
|
self.is_connected_to_shared_instance = False
|
||||||
self.__clean_caches()
|
self.__start_jobs()
|
||||||
|
|
||||||
def __apply_config(self):
|
def __apply_config(self):
|
||||||
if "logging" in self.config:
|
if "logging" in self.config:
|
||||||
|
Loading…
Reference in New Issue
Block a user