Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:22

0001 #!/usr/bin/env python
0002 #
0003 # Licensed under the Apache License, Version 2.0 (the "License");
0004 # You may not use this file except in compliance with the License.
0005 # You may obtain a copy of the License at
0006 # http://www.apache.org/licenses/LICENSE-2.0OA
0007 #
0008 # Authors:
0009 # - Wen Guan, <wen.guan@cern.ch>, 2023
0010 
0011 import socket
0012 from idds.common.utils import pid_exists
0013 from idds.core import health as core_health
0014 
0015 
0016 def clean_heartbeat():
0017     hostname = socket.getfqdn()
0018     health_items = core_health.retrieve_health_items()
0019     pids, pid_not_exists = [], []
0020     for health_item in health_items:
0021         if health_item['hostname'] == hostname:
0022             pid = health_item['pid']
0023             if pid not in pids:
0024                 pids.append(pid)
0025     for pid in pids:
0026         if not pid_exists(pid):
0027             pid_not_exists.append(pid)
0028     if pid_not_exists:
0029         core_health.clean_health(hostname=hostname, pids=pid_not_exists, older_than=None)
0030 
0031 
0032 if __name__ == "__main__":
0033     clean_heartbeat()