1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-21 15:51:52 -05:00

Only load EmailStats if email is enabled

This patch updates the stats collector to only register the EmailStats
when the email plugin is enabled.
This commit is contained in:
Hemna 2024-11-06 08:43:25 -05:00
parent 229155d0ee
commit 2fdc7b111d
2 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import imapclient
from oslo_config import cfg from oslo_config import cfg
from aprsd import packets, plugin, threads, utils from aprsd import packets, plugin, threads, utils
from aprsd.stats import collector
from aprsd.threads import tx from aprsd.threads import tx
from aprsd.utils import trace from aprsd.utils import trace
@ -126,6 +127,11 @@ class EmailPlugin(plugin.APRSDRegexCommandPluginBase):
shortcuts = _build_shortcuts_dict() shortcuts = _build_shortcuts_dict()
LOG.info(f"Email shortcuts {shortcuts}") LOG.info(f"Email shortcuts {shortcuts}")
# Register the EmailStats producer with the stats collector
# We do this here to prevent EmailStats from being registered
# when email is not enabled in the config file.
collector.Collector().register_producer(EmailStats)
else: else:
LOG.info("Email services not enabled.") LOG.info("Email services not enabled.")
self.enabled = False self.enabled = False

View File

@ -1,7 +1,6 @@
from aprsd import plugin from aprsd import plugin
from aprsd.client import stats as client_stats from aprsd.client import stats as client_stats
from aprsd.packets import packet_list, seen_list, tracker, watch_list from aprsd.packets import packet_list, seen_list, tracker, watch_list
from aprsd.plugins import email
from aprsd.stats import app, collector from aprsd.stats import app, collector
from aprsd.threads import aprsd from aprsd.threads import aprsd
@ -15,6 +14,5 @@ stats_collector.register_producer(watch_list.WatchList)
stats_collector.register_producer(tracker.PacketTrack) stats_collector.register_producer(tracker.PacketTrack)
stats_collector.register_producer(plugin.PluginManager) stats_collector.register_producer(plugin.PluginManager)
stats_collector.register_producer(aprsd.APRSDThreadList) stats_collector.register_producer(aprsd.APRSDThreadList)
stats_collector.register_producer(email.EmailStats)
stats_collector.register_producer(client_stats.APRSClientStats) stats_collector.register_producer(client_stats.APRSClientStats)
stats_collector.register_producer(seen_list.SeenList) stats_collector.register_producer(seen_list.SeenList)