mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-11 20:01:35 +00:00
Added a basic health check endpoint to the server
This commit is contained in:
parent
7fe9f8e092
commit
b60d0d112c
1 changed files with 6 additions and 1 deletions
|
@ -14,6 +14,7 @@ import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
import websockets
|
import websockets
|
||||||
import argparse
|
import argparse
|
||||||
|
import http
|
||||||
|
|
||||||
from concurrent.futures._base import TimeoutError
|
from concurrent.futures._base import TimeoutError
|
||||||
|
|
||||||
|
@ -46,6 +47,10 @@ rooms = dict()
|
||||||
|
|
||||||
############### Helper functions ###############
|
############### Helper functions ###############
|
||||||
|
|
||||||
|
async def health_check(path, request_headers):
|
||||||
|
if path == "/health/":
|
||||||
|
return http.HTTPStatus.OK, [], b"OK\n"
|
||||||
|
|
||||||
async def recv_msg_ping(ws, raddr):
|
async def recv_msg_ping(ws, raddr):
|
||||||
'''
|
'''
|
||||||
Wait for a message forever, and send a regular ping to prevent bad routers
|
Wait for a message forever, and send a regular ping to prevent bad routers
|
||||||
|
@ -265,7 +270,7 @@ if not options.disable_ssl:
|
||||||
|
|
||||||
print("Listening on https://{}:{}".format(*ADDR_PORT))
|
print("Listening on https://{}:{}".format(*ADDR_PORT))
|
||||||
# Websocket server
|
# Websocket server
|
||||||
wsd = websockets.serve(handler, *ADDR_PORT, ssl=sslctx,
|
wsd = websockets.serve(handler, *ADDR_PORT, ssl=sslctx, process_request=health_check,
|
||||||
# Maximum number of messages that websockets will pop
|
# Maximum number of messages that websockets will pop
|
||||||
# off the asyncio and OS buffers per connection. See:
|
# off the asyncio and OS buffers per connection. See:
|
||||||
# https://websockets.readthedocs.io/en/stable/api.html#websockets.protocol.WebSocketCommonProtocol
|
# https://websockets.readthedocs.io/en/stable/api.html#websockets.protocol.WebSocketCommonProtocol
|
||||||
|
|
Loading…
Reference in a new issue