From f4ea1dc54427abb6005f15e0118a438e372ce031 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 12 Dec 2023 14:51:47 +0800 Subject: [PATCH] Update index.py --- plugins/mongodb/index.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index 673f42a83..8ef7a3470 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -4,6 +4,7 @@ import sys import io import os import time +import re sys.path.append(os.getcwd() + "/class/core") import mw @@ -49,6 +50,13 @@ def getInitDTpl(): return path +def getConfPort(): + file = getConf() + content = mw.readFile(file) + rep = 'port\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + def getArgs(): args = sys.argv[2:] tmp = {} @@ -160,7 +168,8 @@ def restart(): def runInfo(): import pymongo - client = pymongo.MongoClient(host='127.0.0.1', port=27017) + port = getConfPort() + client = pymongo.MongoClient(host='127.0.0.1', port=int(port)) db = client.admin serverStatus = db.command('serverStatus')