Skip to content
Snippets Groups Projects
Commit 095c44eb authored by Johannes Zumthurm's avatar Johannes Zumthurm
Browse files

check db conn

parent 69a7aca4
No related branches found
No related tags found
1 merge request!677Gitlab ci
Pipeline #287430 canceled
......@@ -6,15 +6,7 @@ test:
before_script:
- pip install --upgrade pip
- pip install tox
- python -c "import socket, time; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); \
while True: \
try: \
s.connect(('mongodb', 27017)); \
s.close(); \
break; \
except socket.error: \
print('Waiting for MongoDB on port 27017...'); \
time.sleep(1)"
- python wait_for_mongodb.py
script:
- tox
artifacts:
......
# wait_for_mongodb.py
import socket
import time
def wait_for_mongodb(host='mongodb', port=27017):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
try:
s.connect((host, port))
s.close()
print("MongoDB is reachable on port 27017")
break
except socket.error:
print("Waiting for MongoDB on port 27017...")
time.sleep(1)
if __name__ == "__main__":
wait_for_mongodb()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment