From 99e143b68628925f245f9e4bb773215da68dee1d Mon Sep 17 00:00:00 2001 From: dami Date: Tue, 22 Jul 2025 00:10:10 +0800 Subject: [PATCH 1/5] up --- plugins/manticoresearch/index.py | 21 +++++++++++++++++++++ plugins/manticoresearch/install.sh | 1 + 2 files changed, 22 insertions(+) diff --git a/plugins/manticoresearch/index.py b/plugins/manticoresearch/index.py index 01253be3f..9da5d0912 100755 --- a/plugins/manticoresearch/index.py +++ b/plugins/manticoresearch/index.py @@ -277,6 +277,25 @@ def runStatus(): data = mw.httpGet(url) return mw.returnJson(True, 'ok', data) +def runStatusTest(): + s = status() + if s != 'start': + return mw.returnJson(False, '没有启动程序') + + sys.path.append(getPluginDir() + "/class") + import sphinxapi + + sh = sphinxapi.SphinxClient() + port = getMainPort() + sh.SetServer('127.0.0.1', port) + info_status = sh.Status() + + rData = {} + for x in range(len(info_status)): + rData[info_status[x][0]] = info_status[x][1] + + return mw.returnJson(True, 'ok', rData) + def sphinxConfParse(): file = getConf() @@ -454,6 +473,8 @@ if __name__ == "__main__": print(queryLog()) elif func == 'run_status': print(runStatus()) + elif func == 'run_status_test': + print(runStatusTest()) elif func == 'sphinx_cmd': print(sphinxCmd()) elif func == 'db_to_sphinx': diff --git a/plugins/manticoresearch/install.sh b/plugins/manticoresearch/install.sh index ef16494fc..0678329c3 100755 --- a/plugins/manticoresearch/install.sh +++ b/plugins/manticoresearch/install.sh @@ -10,6 +10,7 @@ sysName=`uname` sysArch=`arch` # cd /www/server/mdserver-web/plugins/manticoresearch && bash install.sh install 7.4.6 +# cd /www/server/mdserver-web && python3 plugins/manticoresearch/index.py run_status_test # systemctl status manticore if [ -f ${rootPath}/bin/activate ];then From b9057da526f96e163c5388413b1f77f60d8b7245 Mon Sep 17 00:00:00 2001 From: dami Date: Tue, 22 Jul 2025 00:14:05 +0800 Subject: [PATCH 2/5] Update index.py --- plugins/manticoresearch/index.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/manticoresearch/index.py b/plugins/manticoresearch/index.py index 9da5d0912..23f7c7696 100755 --- a/plugins/manticoresearch/index.py +++ b/plugins/manticoresearch/index.py @@ -272,10 +272,19 @@ def runStatus(): if s != 'start': return mw.returnJson(False, '没有启动程序') - port = getHttpPort() - url = "http://127.0.0.1:"+port+"/status" - data = mw.httpGet(url) - return mw.returnJson(True, 'ok', data) + sys.path.append(getPluginDir() + "/class") + import sphinxapi + + sh = sphinxapi.SphinxClient() + port = getMainPort() + sh.SetServer('127.0.0.1', port) + info_status = sh.Status() + + rData = {} + for x in range(len(info_status)): + rData[info_status[x][0]] = info_status[x][1] + + return mw.returnJson(True, 'ok', rData) def runStatusTest(): s = status() From 7600ef1b30467b16a8d78c891bbe1894e022885e Mon Sep 17 00:00:00 2001 From: dami Date: Tue, 22 Jul 2025 00:14:54 +0800 Subject: [PATCH 3/5] Update index.html --- plugins/manticoresearch/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/manticoresearch/index.html b/plugins/manticoresearch/index.html index c87b57169..b625d8f91 100755 --- a/plugins/manticoresearch/index.html +++ b/plugins/manticoresearch/index.html @@ -19,7 +19,7 @@

配置修改

运行日志

查询日志

- +

运行状态

常用功能

说明

From c1e358e9fde5402f378c57d08a5207033e9683d4 Mon Sep 17 00:00:00 2001 From: dami Date: Tue, 22 Jul 2025 00:33:01 +0800 Subject: [PATCH 4/5] Update index.py --- plugins/manticoresearch/index.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/manticoresearch/index.py b/plugins/manticoresearch/index.py index 23f7c7696..ca3f0f001 100755 --- a/plugins/manticoresearch/index.py +++ b/plugins/manticoresearch/index.py @@ -128,6 +128,13 @@ def mkdirAll(): else: mw.execShell('mkdir -p ' + os.path.dirname(x)) +def isInitFile(): + path = getServerDir() + '/init.pl' + if os.path.exists(path): + return True + mw.writeFile(path, 'ok') + return False + def initDreplace(): dirs_list = [ @@ -145,7 +152,7 @@ def initDreplace(): # config replace conf_bin = getConf() - if not os.path.exists(conf_bin): + if not os.path.exists(conf_bin) && not isInitFile(): conf_content = mw.readFile(getConfTpl()) conf_content = contentReplace(conf_content) mw.writeFile(getConf(), conf_content) From 502cb1595fae8a3a0c5c0a7b326c3c46a35e3288 Mon Sep 17 00:00:00 2001 From: dami Date: Tue, 22 Jul 2025 00:33:13 +0800 Subject: [PATCH 5/5] Update index.py --- plugins/manticoresearch/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/manticoresearch/index.py b/plugins/manticoresearch/index.py index ca3f0f001..7a96ba750 100755 --- a/plugins/manticoresearch/index.py +++ b/plugins/manticoresearch/index.py @@ -152,7 +152,7 @@ def initDreplace(): # config replace conf_bin = getConf() - if not os.path.exists(conf_bin) && not isInitFile(): + if not os.path.exists(conf_bin) or not isInitFile(): conf_content = mw.readFile(getConfTpl()) conf_content = contentReplace(conf_content) mw.writeFile(getConf(), conf_content)