diff --git a/plugins/sphinx/index.py b/plugins/sphinx/index.py index 2e42790f0..75e8a3f4a 100755 --- a/plugins/sphinx/index.py +++ b/plugins/sphinx/index.py @@ -5,6 +5,7 @@ import io import os import time import re +import string import subprocess sys.path.append(os.getcwd() + "/class/core") @@ -235,11 +236,30 @@ def runStatus(): def sphinxCmd(): file = getConf() + bin_dir = getServerDir() content = public.readFile(file) - print content rep = 'index\s(.*)' - tmp = re.findall(rep, content) - print tmp + sindex = re.findall(rep, content) + indexlen = len(sindex) + if indexlen > 0: + cmd = {} + cmd_index = [] + cmd_delta = [] + for x in range(indexlen): + if string.find(sindex[x], ':') != -1: + t = sindex[x].split(':') + cmd_delta.append(t[0].strip()) + else: + cmd_index.append(sindex[x]) + + cmd['index'] = cmd_index + cmd['delta'] = cmd_delta + cmd['cmd'] = bin_dir + '/bin/bin/searchd -c ' + bin_dir + '/sphinx.conf' + + return public.returnJson(True, 'ok', cmd) + else: + return public.returnJson(False, 'no index') + if __name__ == "__main__": func = sys.argv[1] diff --git a/plugins/sphinx/js/sphinx.js b/plugins/sphinx/js/sphinx.js index 5c64d94fd..b652ffec8 100755 --- a/plugins/sphinx/js/sphinx.js +++ b/plugins/sphinx/js/sphinx.js @@ -55,7 +55,7 @@ function runStatus(){ } var idata = rdata.data; console.log(idata); - var Con = '
\ + var con = '
\ \ \ \ @@ -77,13 +77,25 @@ function runStatus(){ \
运行时间' + idata.uptime + 's每秒查询' + parseInt(parseInt(idata.queries) / parseInt(idata.uptime)) + '
总连接次数' + idata.connections + 'work_queue_length' +idata.work_queue_length + '
'; - $(".soft-man-con").html(Con); + $(".soft-man-con").html(con); }); } function readme(){ - + spPost('sphinx_cmd', '', function(data){ + var rdata = $.parseJSON(data.data); + if (!rdata['status']){ + layer.msg(rdata['msg'],{icon:2,time:2000,shade: [0.3, '#000']}); + return; + } - $(".soft-man-con").html(Con); + var con = ''; + + console.log(rdata); + + $(".soft-man-con").html(con); + }); + + } diff --git a/plugins/sphinx/tpl/simdht.conf b/plugins/sphinx/tpl/simdht.conf new file mode 100755 index 000000000..96a83a137 --- /dev/null +++ b/plugins/sphinx/tpl/simdht.conf @@ -0,0 +1,24 @@ +# +# Minimal Sphinx configuration sample (clean, simple, functional) +# + +indexer +{ + mem_limit = 218M +} + +searchd +{ + listen = 9312 + listen = 9306:mysql41 + log = {$SERVER_APP}/index/searchd.log + query_log = {$SERVER_APP}/index/query.log + read_timeout = 5 + max_children = 0 + pid_file = {$SERVER_APP}/index/searchd.pid + seamless_rotate = 1 + preopen_indexes = 1 + unlink_old = 1 + #workers = threads # for RT to work + binlog_path = {$SERVER_APP}/index/binlog +}