test with redfish logout
This commit is contained in:
@@ -269,16 +269,18 @@ async def run_exporter(config, stop_event):
|
||||
# Connection pooling with aiohttp
|
||||
connector = aiohttp.TCPConnector(limit_per_host=5, limit=50, ttl_dns_cache=300)
|
||||
async with aiohttp.ClientSession(connector=connector) as session:
|
||||
hosts = [HostConfig(**h) for h in config["hosts"]]
|
||||
while not stop_event.is_set():
|
||||
tasks = [get_power_data(session, hc) for hc in host_objs]
|
||||
|
||||
await asyncio.gather(*tasks)
|
||||
await process_request(interval)
|
||||
# shutdown service
|
||||
try:
|
||||
while not stop_event.is_set():
|
||||
tasks = [get_power_data(session, hc) for hc in host_objs]
|
||||
await asyncio.gather(*tasks)
|
||||
await process_request(interval)
|
||||
finally:
|
||||
# Graceful shutdown: logout from Redfish sessions
|
||||
logging.info("Exporter stopping, logging out from Redfish sessions...")
|
||||
await asyncio.gather(*(logout_host(session, h) for h in hosts if h.session_token))
|
||||
|
||||
await asyncio.gather(
|
||||
*(logout_host(session, h) for h in host_objs if h.session_token)
|
||||
)
|
||||
logging.info("All sessions logged out.")
|
||||
logging.info("Exporter stopped cleanly.")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user