| | import requests |
| | import time |
| | import os |
| | import logging |
| | from threading import Timer |
| |
|
| | |
| | URL = os.getenv('MASTER_URL', 'http://localhost:8000/hc') |
| | HOST_URL = os.getenv('SENDER_URL', 'http://my-sender-host.com') |
| | INTERVAL = int(os.getenv('SENDER_INTERVAL', '43200')) |
| |
|
| | def send_timestamp(): |
| | try: |
| | response = requests.get(URL, params={ |
| | 'timestamp': time.time(), |
| | 'host_url': HOST_URL |
| | }) |
| | logging.info(f"Sent timestamp to {URL}: {response.status_code}") |
| | except Exception as e: |
| | logging.info(f"Error sending timestamp to {URL}: {type(e).__name__}: {e}") |
| | |
| | |
| | Timer(INTERVAL, send_timestamp).start() |
| | logging.info(f"Scheduled next timestamp send in {INTERVAL} seconds") |
| |
|
| | |
| | logging.info(f"Starting timestamp sender to {URL} every {INTERVAL} seconds") |
| | send_timestamp() |