import hashlib import os import urllib.request from pathlib import Path import sys sys.path.insert(0, '/www/server/xingyu-im/ops') from baota_publish_test_users import BT expected = 'e8344e81cc828e6817bc7c232a261884fbb5d7e8123420da121ede908502329e' binary = BT / 'xingyu-api' actual = hashlib.sha256(binary.read_bytes()).hexdigest() pids = [] for proc in Path('/proc').iterdir(): if not proc.name.isdigit(): continue try: if os.readlink(str(proc / 'exe')) == str(binary): pids.append(int(proc.name)) except (FileNotFoundError, PermissionError): pass with urllib.request.urlopen('https://im.bchongw.com/healthz', timeout=20) as response: health = response.status print({ 'backendSha256': actual, 'backendMatches': actual == expected, 'runningPids': pids, 'healthStatus': health, 'h5Target': os.path.realpath('/www/wwwroot/im.bchongw.com/app'), })