Address feedback. Broaden logging to more types of Exception.
This commit is contained in:
parent
8b7d1afd19
commit
4ce3661631
2 changed files with 23 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import typing
|
import typing
|
||||||
|
@ -55,9 +56,24 @@ class ElasticSyncService(BlockchainReaderService):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def run_es_notifier(self, synchronized: asyncio.Event):
|
async def run_es_notifier(self, synchronized: asyncio.Event):
|
||||||
server = await asyncio.get_event_loop().create_server(
|
started = False
|
||||||
lambda: ElasticNotifierProtocol(self._listeners), self.env.elastic_notifier_host, self.env.elastic_notifier_port
|
while not started:
|
||||||
)
|
try:
|
||||||
|
server = await asyncio.get_event_loop().create_server(
|
||||||
|
lambda: ElasticNotifierProtocol(self._listeners),
|
||||||
|
self.env.elastic_notifier_host,
|
||||||
|
self.env.elastic_notifier_port
|
||||||
|
)
|
||||||
|
started = True
|
||||||
|
except Exception as e:
|
||||||
|
if not isinstance(e, asyncio.CancelledError):
|
||||||
|
self.log.error(f'ES notifier server failed to listen on '
|
||||||
|
f'{self.env.elastic_notifier_host}:'
|
||||||
|
f'{self.env.elastic_notifier_port:d} : {e!r}')
|
||||||
|
if isinstance(e, OSError) and e.errno is errno.EADDRINUSE:
|
||||||
|
await asyncio.sleep(3)
|
||||||
|
continue
|
||||||
|
raise
|
||||||
self.log.info("ES notifier server listening on TCP %s:%i", self.env.elastic_notifier_host,
|
self.log.info("ES notifier server listening on TCP %s:%i", self.env.elastic_notifier_host,
|
||||||
self.env.elastic_notifier_port)
|
self.env.elastic_notifier_port)
|
||||||
synchronized.set()
|
synchronized.set()
|
||||||
|
|
|
@ -271,9 +271,10 @@ class SessionManager:
|
||||||
host, port = args[:2]
|
host, port = args[:2]
|
||||||
try:
|
try:
|
||||||
self.servers[kind] = await loop.create_server(protocol_factory, *args, **kw_args)
|
self.servers[kind] = await loop.create_server(protocol_factory, *args, **kw_args)
|
||||||
except OSError as e: # don't suppress CancelledError
|
except Exception as e:
|
||||||
self.logger.error(f'{kind} server failed to listen on {host}:'
|
if not isinstance(e, asyncio.CancelledError):
|
||||||
f'{port:d} :{e!r}')
|
self.logger.error(f'{kind} server failed to listen on '
|
||||||
|
f'{host}:{port:d} : {e!r}')
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
self.logger.info(f'{kind} server listening on {host}:{port:d}')
|
self.logger.info(f'{kind} server listening on {host}:{port:d}')
|
||||||
|
|
Loading…
Reference in a new issue