mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 16:59:25 +00:00
Instantiate but disable providers. Closes #16
This commit is contained in:
30
main.py
30
main.py
@@ -35,32 +35,34 @@ def shutdown(sig, frame):
|
||||
logging.info("Stopping program, this may take a few seconds...")
|
||||
global run
|
||||
run = False
|
||||
for p in providers: p.stop()
|
||||
for p in providers:
|
||||
if p.enabled:
|
||||
p.stop()
|
||||
cleanup_timer.stop()
|
||||
|
||||
# Utility method to get a data provider based on its config entry.
|
||||
def get_provider_from_config(config_providers_entry):
|
||||
match config_providers_entry["type"]:
|
||||
case "POTA":
|
||||
return POTA()
|
||||
return POTA(config_providers_entry)
|
||||
case "SOTA":
|
||||
return SOTA()
|
||||
return SOTA(config_providers_entry)
|
||||
case "WWFF":
|
||||
return WWFF()
|
||||
return WWFF(config_providers_entry)
|
||||
case "GMA":
|
||||
return GMA()
|
||||
return GMA(config_providers_entry)
|
||||
case "WWBOTA":
|
||||
return WWBOTA()
|
||||
return WWBOTA(config_providers_entry)
|
||||
case "HEMA":
|
||||
return HEMA()
|
||||
return HEMA(config_providers_entry)
|
||||
case "ParksNPeaks":
|
||||
return ParksNPeaks()
|
||||
return ParksNPeaks(config_providers_entry)
|
||||
case "DXCluster":
|
||||
return DXCluster(config_providers_entry["host"], config_providers_entry["port"])
|
||||
return DXCluster(config_providers_entry)
|
||||
case "RBN":
|
||||
return RBN(config_providers_entry["port"])
|
||||
return RBN(config_providers_entry)
|
||||
case "APRS-IS":
|
||||
return APRSIS()
|
||||
return APRSIS(config_providers_entry)
|
||||
return None
|
||||
|
||||
|
||||
@@ -85,7 +87,9 @@ if __name__ == '__main__':
|
||||
# Set up data providers
|
||||
for p in providers: p.setup(spot_list=spot_list)
|
||||
# Start data providers
|
||||
for p in providers: p.start()
|
||||
for p in providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
|
||||
# Set up timer to clear spot list of old data
|
||||
cleanup_timer = CleanupTimer(spot_list=spot_list, cleanup_interval=60, max_spot_age=config["max-spot-age-sec"])
|
||||
@@ -103,6 +107,6 @@ if __name__ == '__main__':
|
||||
status_data["uptime"] = str(datetime.now(pytz.UTC) - startup_time).split(".")[0]
|
||||
status_data["mem_use_mb"] = round(psutil.Process(os.getpid()).memory_info().rss / (1024 * 1024), 3)
|
||||
status_data["num_spots"] = len(spot_list)
|
||||
status_data["providers"] = list(map(lambda p: {"name": p.name(), "status": p.status, "last_updated": p.last_update_time, "last_spot": p.last_spot_time}, providers))
|
||||
status_data["providers"] = list(map(lambda p: {"name": p.name, "enabled": p.enabled, "status": p.status, "last_updated": p.last_update_time, "last_spot": p.last_spot_time}, providers))
|
||||
status_data["cleanup"] = {"status": cleanup_timer.status, "last_ran": cleanup_timer.last_cleanup_time}
|
||||
status_data["webserver"] = {"status": web_server.status, "last_api_access": web_server.last_api_access_time, "last_page_access": web_server.last_page_access_time}
|
||||
|
||||
Reference in New Issue
Block a user