22 lines
770 B
Python
22 lines
770 B
Python
"""Check shell, transport, account service and the actual running speech worker."""
|
|
import os
|
|
import ssl
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
|
|
def get(url, *, insecure=False):
|
|
context = ssl._create_unverified_context() if insecure else None
|
|
with urllib.request.urlopen(url, timeout=3, context=context) as response:
|
|
if response.status != 200:
|
|
raise RuntimeError('Service unavailable')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
get(f"https://127.0.0.1:{os.getenv('WEB_PORT', '9178')}/", insecure=True)
|
|
get('http://127.0.0.1:7880/')
|
|
get(os.getenv('CONTROL_URL', 'http://127.0.0.1:8092') + '/health')
|
|
pid, port = map(int, Path('/tmp/hope-worker-health').read_text().split())
|
|
os.kill(pid, 0)
|
|
get(f'http://127.0.0.1:{port}/')
|