list which processes occupy port

This commit is contained in:
Ruben van de Ven 2023-12-06 12:08:12 +01:00
parent 44a618a5ee
commit cd8a06a53b

View file

@ -1,8 +1,10 @@
from argparse import Namespace
import asyncio
import errno
import logging
from multiprocessing import Event
import subprocess
from typing import Set, Union, Dict, Any
from typing_extensions import Self
@ -145,7 +147,14 @@ class WsRouter:
# loop = tornado.ioloop.IOLoop.current()
logger.info(f"Listen on {self.config.ws_port}")
self.application.listen(self.config.ws_port)
try:
self.application.listen(self.config.ws_port)
except OSError as e:
if e.errno == errno.EADDRINUSE:
logger.critical("Address already in use by process")
subprocess.run(["lsof", "-i", f"tcp:{self.config.ws_port:d}"])
raise
loop = asyncio.get_event_loop()
task = self.evt_loop.create_task(self.prediction_forwarder())