You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
535 B
Python
24 lines
535 B
Python
from pymongo import MongoClient
|
|
from pymongo.errors import PyMongoError
|
|
import sys
|
|
import json
|
|
|
|
try:
|
|
client = MongoClient(
|
|
"mongodb://localhost:27017",
|
|
connectTimeoutMS=3000,
|
|
serverSelectionTimeoutMS=5000,
|
|
socketTimeoutMS=5000,
|
|
directConnection=True,
|
|
)
|
|
|
|
client.admin.command("ping")
|
|
print(json.dumps({"ok": 1}))
|
|
sys.exit(0)
|
|
|
|
except PyMongoError as e:
|
|
print(json.dumps({
|
|
"ok": 0,
|
|
"error": str(e)
|
|
}, ensure_ascii=False), file=sys.stderr)
|
|
sys.exit(1) |