Use advanced scheduler by default

This commit is contained in:
Robert Chacón 2023-02-04 11:27:28 -07:00 committed by GitHub
parent 433ffe6a7b
commit 205ec17375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,9 @@ if automaticImportUISP:
from integrationUISP import importFromUISP from integrationUISP import importFromUISP
if automaticImportSplynx: if automaticImportSplynx:
from integrationSplynx import importFromSplynx from integrationSplynx import importFromSplynx
from apscheduler.schedulers.background import BlockingScheduler
ads = BlockingScheduler()
def importFromCRM(): def importFromCRM():
if automaticImportUISP: if automaticImportUISP:
@ -20,6 +23,16 @@ def importFromCRM():
except: except:
print("Failed to import from Splynx") print("Failed to import from Splynx")
def graphHandler():
try:
refreshBandwidthGraphs()
except:
print("Failed to update bandwidth graphs")
try:
refreshLatencyGraphs()
except:
print("Failed to update latency graphs")
def importAndShapeFullReload(): def importAndShapeFullReload():
importFromCRM() importFromCRM()
refreshShapers() refreshShapers()
@ -28,35 +41,12 @@ def importAndShapePartialReload():
importFromCRM() importFromCRM()
refreshShapersUpdateOnly() refreshShapersUpdateOnly()
def graph():
time.sleep(10)
try:
refreshBandwidthGraphs()
except:
print("Failed to run refreshBandwidthGraphs()")
time.sleep(10)
try:
refreshBandwidthGraphs()
except:
print("Failed to run refreshBandwidthGraphs()")
time.sleep(10)
try:
refreshBandwidthGraphs()
except:
print("Failed to run refreshBandwidthGraphs()")
time.sleep(1)
try:
refreshLatencyGraphs()
except:
print("Failed to run refreshLatencyGraphs()")
if __name__ == '__main__': if __name__ == '__main__':
importAndShapeFullReload() importAndShapeFullReload()
while True:
finish_time = datetime.datetime.now() + datetime.timedelta(minutes=30) ads.add_job(importAndShapePartialReload, 'interval', minutes=30)
while datetime.datetime.now() < finish_time:
if influxDBEnabled: if influxDBEnabled:
graph() ads.add_job(graphHandler, 'interval', seconds=10)
else:
time.sleep(1) ads.start()
importAndShapePartialReload()