Implemented ip change checking
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-08 22:21:15 +02:00
parent 7ce88f1a74
commit 0713cabc6b
3 changed files with 47 additions and 17 deletions

9
app.py
View File

@@ -6,6 +6,7 @@ import logging
from redis_super_storage import RedisSuperStorage
from communicators import ConsumerCommunicator, ProducerCommunicator
from ip_watchdog import IPWatchdog
"""
Scheduler
@@ -32,13 +33,21 @@ def main():
redis_storage = RedisSuperStorage(os.environ.get('REDIS_URL', "redis://localhost:6379/0"), 5)
consumer_communicator = ConsumerCommunicator(redis_storage)
producer_communicator = ProducerCommunicator(redis_storage)
ip_watchdog = IPWatchdog(redis_storage)
logging.info("Syncing to initial consumer list")
for ip in get_initial_ip_list():
logging.debug(f"Syncing to {ip}")
consumer_communicator.targeted_snyc(ip)
while True:
logging.debug("Doing a sync")
consumer_communicator.sync_all()
ip_changed, ipaddr = ip_watchdog.ip_changed()
if ip_changed:
producer_communicator.push_ip_update(ipaddr)
time.sleep(os.environ.get("RUN_INTERVAL", 30))