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
if automaticImportSplynx:
from integrationSplynx import importFromSplynx
from apscheduler.schedulers.background import BlockingScheduler
ads = BlockingScheduler()
def importFromCRM():
if automaticImportUISP:
@ -20,6 +23,16 @@ def importFromCRM():
except:
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():
importFromCRM()
refreshShapers()
@ -28,35 +41,12 @@ def importAndShapePartialReload():
importFromCRM()
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__':
importAndShapeFullReload()
while True:
finish_time = datetime.datetime.now() + datetime.timedelta(minutes=30)
while datetime.datetime.now() < finish_time:
if influxDBEnabled:
graph()
else:
time.sleep(1)
importAndShapePartialReload()
ads.add_job(importAndShapePartialReload, 'interval', minutes=30)
if influxDBEnabled:
ads.add_job(graphHandler, 'interval', seconds=10)
ads.start()