Implemented ip change checking
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
9
app.py
9
app.py
@@ -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))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user