Wait for open connection on startup
This commit is contained in:
parent
f4bd0ca1c9
commit
975e9c5369
|
@ -60,10 +60,22 @@ class RPCClient:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.config["puppeteer.connection.type"] == "unix":
|
if self.config["puppeteer.connection.type"] == "unix":
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
r, w = await asyncio.open_unix_connection(self.config["puppeteer.connection.path"])
|
r, w = await asyncio.open_unix_connection(self.config["puppeteer.connection.path"])
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
self.log.warn(f'No unix socket available at {self.config["puppeteer.connection.path"]}, wait for it to exist...')
|
||||||
|
await asyncio.sleep(10)
|
||||||
elif self.config["puppeteer.connection.type"] == "tcp":
|
elif self.config["puppeteer.connection.type"] == "tcp":
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
r, w = await asyncio.open_connection(self.config["puppeteer.connection.host"],
|
r, w = await asyncio.open_connection(self.config["puppeteer.connection.host"],
|
||||||
self.config["puppeteer.connection.port"])
|
self.config["puppeteer.connection.port"])
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
self.log.warn(f'No TCP connection open at {self.config["puppeteer.connection.host"]}:{self.config["puppeteer.connection.path"]}, wait for it to become available...')
|
||||||
|
await asyncio.sleep(10)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("invalid puppeteer connection type")
|
raise RuntimeError("invalid puppeteer connection type")
|
||||||
self._reader = r
|
self._reader = r
|
||||||
|
|
Loading…
Reference in New Issue