Fixed wait for db
This commit is contained in:
parent
39a9566e40
commit
dcf771db9b
@ -2,8 +2,9 @@ import socket
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
port = int(os.environ["SQL_PORT"]) # 5432
|
port = int(os.environ.get("SQL_PORT")) # 5432
|
||||||
db_name = os.environ["SQL_DATABASE"]
|
db_name = os.environ.get("SQL_HOST")
|
||||||
|
print(f"database at {db_name}:{port}")
|
||||||
|
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
while True:
|
while True:
|
||||||
@ -11,5 +12,5 @@ while True:
|
|||||||
s.connect((db_name, port))
|
s.connect((db_name, port))
|
||||||
s.close()
|
s.close()
|
||||||
break
|
break
|
||||||
except socket.error as ex:
|
except socket.error:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
Loading…
Reference in New Issue
Block a user