2017-08-25 22:47:08 +08:00
|
|
|
from flask_pymongo import PyMongo
|
2017-10-31 19:55:29 +08:00
|
|
|
from flask_pymongo import MongoClient
|
|
|
|
from pymongo.errors import ServerSelectionTimeoutError
|
2017-08-25 22:47:08 +08:00
|
|
|
|
|
|
|
__author__ = 'Barak'
|
|
|
|
|
|
|
|
mongo = PyMongo()
|
2017-10-31 19:55:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
def is_db_server_up(mongo_url):
|
|
|
|
client = MongoClient(mongo_url, serverSelectionTimeoutMS=100)
|
|
|
|
try:
|
|
|
|
client.server_info()
|
|
|
|
return True
|
|
|
|
except ServerSelectionTimeoutError:
|
|
|
|
return False
|