This commit is contained in:
parent
a60ee01ae1
commit
a1ca3285ab
9
app.py
9
app.py
@ -7,6 +7,7 @@ import os
|
|||||||
import redis
|
import redis
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import socket
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Scheduler
|
Scheduler
|
||||||
@ -35,6 +36,9 @@ def main():
|
|||||||
consumer_list_redis = json.loads((r.get('consumer_list') or b'{}').decode('utf-8'))
|
consumer_list_redis = json.loads((r.get('consumer_list') or b'{}').decode('utf-8'))
|
||||||
logging.debug('Get consumer list from redis at first: Done')
|
logging.debug('Get consumer list from redis at first: Done')
|
||||||
temp_dict = { }
|
temp_dict = { }
|
||||||
|
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
current_ip = socket.gethostbyname(host_name)
|
||||||
|
|
||||||
for ip in ip_list:
|
for ip in ip_list:
|
||||||
try:
|
try:
|
||||||
@ -58,13 +62,12 @@ def main():
|
|||||||
ip = info['ip']
|
ip = info['ip']
|
||||||
try:
|
try:
|
||||||
# request synchronization
|
# request synchronization
|
||||||
response = requests.post(f"http://{ip}/sync", json = { 'uuid': os.environ['LOCAL_UUID'] })
|
response = requests.post(f"http://{ip}/sync", json={'uuid': os.environ['LOCAL_UUID']})
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
temp_dict[response.json()['uuid']] = { 'ip': ip }
|
temp_dict[response.json()['uuid']] = {'ip': ip}
|
||||||
|
|
||||||
|
|
||||||
# update the dictionary of the currently available consumers
|
# update the dictionary of the currently available consumers
|
||||||
consumer_list_redis.update(temp_dict)
|
consumer_list_redis.update(temp_dict)
|
||||||
|
Reference in New Issue
Block a user