mirror of https://github.com/midoks/mdserver-web
parent
fa9e4e3b06
commit
d3a4db511a
@ -0,0 +1,9 @@ |
||||
global |
||||
log 127.0.0.1 local2 |
||||
chroot /var/lib/haproxy |
||||
pidfile /var/run/haproxy.pid |
||||
maxconn 4000 |
||||
user haproxy |
||||
group haproxy |
||||
daemon |
||||
stats socket /var/lib/haproxy/stats |
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,21 @@ |
||||
<div class="bt-form"> |
||||
<div class="bt-w-main"> |
||||
<div class="bt-w-menu"> |
||||
<p class="bgw" onclick="pluginService('haproxy');">服务</p> |
||||
<p onclick="pluginInitD('haproxy');">自启动</p> |
||||
<p onclick="pluginConfigTpl('haproxy');">配置修改</p> |
||||
<p onclick="pluginLogs('haproxy','','run_log',30);">运行日志</p> |
||||
<p onclick="pluginLogs('haproxy','','query_log', 30);">查询日志</p> |
||||
<p onclick="runStatus();">运行状态</p> |
||||
<p onclick="readme();">说明</p> |
||||
</div> |
||||
<div class="bt-w-con pd15"> |
||||
<div class="soft-man-con"></div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<script type="text/javascript"> |
||||
$.getScript( "/plugins/file?name=haproxy&f=js/haproxy.js", function(){ |
||||
pluginService('haproxy'); |
||||
}); |
||||
</script> |
@ -0,0 +1,355 @@ |
||||
# coding:utf-8 |
||||
|
||||
import sys |
||||
import io |
||||
import os |
||||
import time |
||||
import re |
||||
import string |
||||
import subprocess |
||||
|
||||
sys.path.append(os.getcwd() + "/class/core") |
||||
import mw |
||||
|
||||
app_debug = False |
||||
if mw.isAppleSystem(): |
||||
app_debug = True |
||||
|
||||
|
||||
def getPluginName(): |
||||
return 'haproxy' |
||||
|
||||
|
||||
def getPluginDir(): |
||||
return mw.getPluginDir() + '/' + getPluginName() |
||||
|
||||
|
||||
def getServerDir(): |
||||
return mw.getServerDir() + '/' + getPluginName() |
||||
|
||||
|
||||
def getInitDFile(): |
||||
if app_debug: |
||||
return '/tmp/' + getPluginName() |
||||
return '/etc/init.d/' + getPluginName() |
||||
|
||||
|
||||
def getConfTpl(): |
||||
path = getPluginDir() + "/conf/haproxy.conf" |
||||
return path |
||||
|
||||
|
||||
def getConf(): |
||||
path = getServerDir() + "/sphinx.conf" |
||||
return path |
||||
|
||||
|
||||
def getInitDTpl(): |
||||
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl" |
||||
return path |
||||
|
||||
|
||||
def getArgs(): |
||||
args = sys.argv[2:] |
||||
tmp = {} |
||||
args_len = len(args) |
||||
|
||||
if args_len == 1: |
||||
t = args[0].strip('{').strip('}') |
||||
t = t.split(':') |
||||
tmp[t[0]] = t[1] |
||||
elif args_len > 1: |
||||
for i in range(len(args)): |
||||
t = args[i].split(':') |
||||
tmp[t[0]] = t[1] |
||||
return tmp |
||||
|
||||
|
||||
def checkArgs(data, ck=[]): |
||||
for i in range(len(ck)): |
||||
if not ck[i] in data: |
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) |
||||
return (True, mw.returnJson(True, 'ok')) |
||||
|
||||
|
||||
def configTpl(): |
||||
path = getPluginDir() + '/tpl' |
||||
pathFile = os.listdir(path) |
||||
tmp = [] |
||||
for one in pathFile: |
||||
file = path + '/' + one |
||||
tmp.append(file) |
||||
return mw.getJson(tmp) |
||||
|
||||
|
||||
def readConfigTpl(): |
||||
args = getArgs() |
||||
data = checkArgs(args, ['file']) |
||||
if not data[0]: |
||||
return data[1] |
||||
|
||||
content = mw.readFile(args['file']) |
||||
content = contentReplace(content) |
||||
return mw.returnJson(True, 'ok', content) |
||||
|
||||
|
||||
def contentReplace(content): |
||||
service_path = mw.getServerDir() |
||||
content = content.replace('{$ROOT_PATH}', mw.getRootDir()) |
||||
content = content.replace('{$SERVER_PATH}', service_path) |
||||
content = content.replace('{$SERVER_APP}', service_path + '/haproxy') |
||||
return content |
||||
|
||||
|
||||
def status(): |
||||
data = mw.execShell( |
||||
"ps -ef|grep haproxy |grep -v grep | grep -v python | awk '{print $2}'") |
||||
if data[0] == '': |
||||
return 'stop' |
||||
return 'start' |
||||
|
||||
|
||||
def mkdirAll(): |
||||
content = mw.readFile(getConf()) |
||||
rep = 'path\s*=\s*(.*)' |
||||
p = re.compile(rep) |
||||
tmp = p.findall(content) |
||||
|
||||
for x in tmp: |
||||
if x.find('binlog') != -1: |
||||
mw.execShell('mkdir -p ' + x) |
||||
else: |
||||
mw.execShell('mkdir -p ' + os.path.dirname(x)) |
||||
|
||||
|
||||
def initDreplace(): |
||||
|
||||
file_tpl = getInitDTpl() |
||||
service_path = os.path.dirname(os.getcwd()) |
||||
|
||||
initD_path = getServerDir() + '/init.d' |
||||
if not os.path.exists(initD_path): |
||||
os.mkdir(initD_path) |
||||
file_bin = initD_path + '/' + getPluginName() |
||||
|
||||
# initd replace |
||||
if not os.path.exists(file_bin): |
||||
content = mw.readFile(file_tpl) |
||||
content = contentReplace(content) |
||||
mw.writeFile(file_bin, content) |
||||
mw.execShell('chmod +x ' + file_bin) |
||||
|
||||
# config replace |
||||
conf_bin = getConf() |
||||
if not os.path.exists(conf_bin): |
||||
conf_content = mw.readFile(getConfTpl()) |
||||
conf_content = contentReplace(conf_content) |
||||
mw.writeFile(getServerDir() + '/haproxy.conf', conf_content) |
||||
|
||||
# systemd |
||||
systemDir = mw.systemdCfgDir() |
||||
systemService = systemDir + '/haproxy.service' |
||||
systemServiceTpl = getPluginDir() + '/init.d/haproxy.service.tpl' |
||||
if os.path.exists(systemDir) and not os.path.exists(systemService): |
||||
service_path = mw.getServerDir() |
||||
se_content = mw.readFile(systemServiceTpl) |
||||
se_content = se_content.replace('{$SERVER_PATH}', service_path) |
||||
mw.writeFile(systemService, se_content) |
||||
mw.execShell('systemctl daemon-reload') |
||||
|
||||
mkdirAll() |
||||
return file_bin |
||||
|
||||
|
||||
def checkIndexSph(): |
||||
content = mw.readFile(getConf()) |
||||
rep = 'path\s*=\s*(.*)' |
||||
p = re.compile(rep) |
||||
tmp = p.findall(content) |
||||
for x in tmp: |
||||
if x.find('binlog') != -1: |
||||
continue |
||||
else: |
||||
p = x + '.sph' |
||||
if os.path.exists(p): |
||||
return False |
||||
return True |
||||
|
||||
|
||||
def sphOp(method): |
||||
file = initDreplace() |
||||
|
||||
if not mw.isAppleSystem(): |
||||
data = mw.execShell('systemctl ' + method + ' haproxy') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return 'fail' |
||||
|
||||
data = mw.execShell(file + ' ' + method) |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return data[1] |
||||
|
||||
|
||||
def start(): |
||||
return sphOp('start') |
||||
|
||||
|
||||
def stop(): |
||||
return sphOp('stop') |
||||
|
||||
|
||||
def restart(): |
||||
return sphOp('restart') |
||||
|
||||
|
||||
def reload(): |
||||
return sphOp('reload') |
||||
|
||||
|
||||
def rebuild(): |
||||
file = initDreplace() |
||||
subprocess.Popen(file + ' rebuild &', |
||||
stdout=subprocess.PIPE, shell=True) |
||||
# data = mw.execShell(file + ' rebuild') |
||||
return 'ok' |
||||
|
||||
|
||||
def initdStatus(): |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
shell_cmd = 'systemctl status haproxy | grep loaded | grep "enabled;"' |
||||
data = mw.execShell(shell_cmd) |
||||
if data[0] == '': |
||||
return 'fail' |
||||
return 'ok' |
||||
|
||||
|
||||
def initdInstall(): |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
mw.execShell('systemctl enable haproxy') |
||||
return 'ok' |
||||
|
||||
|
||||
def initdUinstall(): |
||||
if mw.isAppleSystem(): |
||||
return "Apple Computer does not support" |
||||
|
||||
mw.execShell('systemctl disable haproxy') |
||||
return 'ok' |
||||
|
||||
|
||||
def runLog(): |
||||
path = getConf() |
||||
content = mw.readFile(path) |
||||
rep = 'log\s*=\s*(.*)' |
||||
tmp = re.search(rep, content) |
||||
return tmp.groups()[0] |
||||
|
||||
|
||||
def getPort(): |
||||
path = getConf() |
||||
content = mw.readFile(path) |
||||
rep = 'listen\s*=\s*(.*)' |
||||
tmp = re.search(rep, content) |
||||
return tmp.groups()[0] |
||||
|
||||
|
||||
def queryLog(): |
||||
path = getConf() |
||||
content = mw.readFile(path) |
||||
rep = 'query_log\s*=\s*(.*)' |
||||
tmp = re.search(rep, content) |
||||
return tmp.groups()[0] |
||||
|
||||
|
||||
def runStatus(): |
||||
s = status() |
||||
if s != 'start': |
||||
return mw.returnJson(False, '没有启动程序') |
||||
|
||||
sys.path.append(getPluginDir() + "/class") |
||||
import sphinxapi |
||||
|
||||
sh = sphinxapi.SphinxClient() |
||||
port = getPort() |
||||
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() |
||||
bin_dir = getServerDir() |
||||
content = mw.readFile(file) |
||||
rep = 'index\s(.*)' |
||||
sindex = re.findall(rep, content) |
||||
indexlen = len(sindex) |
||||
cmd = {} |
||||
if indexlen > 0: |
||||
cmd_index = [] |
||||
cmd_delta = [] |
||||
for x in range(indexlen): |
||||
if sindex[x].find(':') != -1: |
||||
cmd_delta.append(sindex[x]) |
||||
else: |
||||
cmd_index.append(sindex[x]) |
||||
|
||||
cmd['index'] = cmd_index |
||||
cmd['delta'] = cmd_delta |
||||
cmd['cmd'] = bin_dir + '/bin/bin/indexer -c ' + bin_dir + '/sphinx.conf' |
||||
return cmd |
||||
|
||||
|
||||
def sphinxCmd(): |
||||
data = sphinxConfParse() |
||||
if 'index' in data: |
||||
return mw.returnJson(True, 'ok', data) |
||||
else: |
||||
return mw.returnJson(False, 'no index') |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
func = sys.argv[1] |
||||
if func == 'status': |
||||
print(status()) |
||||
elif func == 'start': |
||||
print(start()) |
||||
elif func == 'stop': |
||||
print(stop()) |
||||
elif func == 'restart': |
||||
print(restart()) |
||||
elif func == 'reload': |
||||
print(reload()) |
||||
elif func == 'rebuild': |
||||
print(rebuild()) |
||||
elif func == 'initd_status': |
||||
print(initdStatus()) |
||||
elif func == 'initd_install': |
||||
print(initdInstall()) |
||||
elif func == 'initd_uninstall': |
||||
print(initdUinstall()) |
||||
elif func == 'conf': |
||||
print(getConf()) |
||||
elif func == 'config_tpl': |
||||
print(configTpl()) |
||||
elif func == 'read_config_tpl': |
||||
print(readConfigTpl()) |
||||
elif func == 'run_log': |
||||
print(runLog()) |
||||
elif func == 'query_log': |
||||
print(queryLog()) |
||||
elif func == 'run_status': |
||||
print(runStatus()) |
||||
elif func == 'sphinx_cmd': |
||||
print(sphinxCmd()) |
||||
else: |
||||
print('error') |
@ -0,0 +1,19 @@ |
||||
{ |
||||
"sort": 7, |
||||
"ps": "可靠、高性能的TCP/HTTP负载平衡器", |
||||
"name": "haproxy", |
||||
"title": "haproxy", |
||||
"shell": "install.sh", |
||||
"versions":["2.6"], |
||||
"updates":["2.6"], |
||||
"tip": "soft", |
||||
"checks": "server/haproxy", |
||||
"path": "server/haproxy", |
||||
"display": 1, |
||||
"author": "midoks", |
||||
"date": "2022-08-26", |
||||
"home": "https://www.haproxy.org/", |
||||
"doc1": "https://www.haproxy.org/", |
||||
"type": 0, |
||||
"pid": "4" |
||||
} |
@ -0,0 +1,12 @@ |
||||
[Unit] |
||||
Description=he Reliable, High Performance TCP/HTTP Load Balancer |
||||
After=network.target |
||||
|
||||
[Service] |
||||
Type=forking |
||||
ExecStart={$SERVER_PATH}/sphinx/bin/bin/searchd -c {$SERVER_PATH}/sphinx/sphinx.conf |
||||
ExecReload=/bin/kill -USR2 $MAINPID |
||||
Restart=on-failure |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
@ -0,0 +1,82 @@ |
||||
#! /bin/bash |
||||
# |
||||
# searchd: sphinx Daemon |
||||
# |
||||
# chkconfig: - 90 25 |
||||
# description: sphinx Daemon |
||||
# |
||||
### BEGIN INIT INFO |
||||
# Provides: sphinx |
||||
# Required-Start: $syslog |
||||
# Required-Stop: $syslog |
||||
# Should-Start: $local_fs |
||||
# Should-Stop: $local_fs |
||||
# Default-Start: 2 3 4 5 |
||||
# Default-Stop: 0 1 6 |
||||
# Short-Description: sphinx - Document Index Daemon |
||||
# Description: sphinx - Document Index Daemon |
||||
### END INIT INFO |
||||
|
||||
APP_PATH={$SERVER_APP} |
||||
APP_CONF={$SERVER_APP}/sphinx.conf |
||||
prog="sphinx" |
||||
|
||||
start () { |
||||
echo -n $"Starting $prog: " |
||||
${APP_PATH}/bin/bin/searchd -c ${APP_CONF} |
||||
if [ "$?" != 0 ] ; then |
||||
echo " failed" |
||||
exit 1 |
||||
else |
||||
echo " done" |
||||
fi |
||||
} |
||||
|
||||
rebuild () { |
||||
${APP_PATH}/bin/bin/indexer -c ${APP_CONF} --all --rotate & |
||||
} |
||||
|
||||
|
||||
stop () { |
||||
echo -n $"Stopping $prog: " |
||||
if [ ! -e ${APP_PATH}/index/searchd.pid ]; then |
||||
echo -n $"$prog is not running." |
||||
exit 1 |
||||
fi |
||||
kill `cat ${APP_PATH}/index/searchd.pid` |
||||
if [ "$?" != 0 ] ; then |
||||
echo " failed" |
||||
exit 1 |
||||
else |
||||
rm -f ${APP_PATH}/index/searchd.pid |
||||
echo " done" |
||||
fi |
||||
} |
||||
|
||||
restart () { |
||||
$0 stop |
||||
sleep 2 |
||||
$0 start |
||||
} |
||||
|
||||
# See how we were called. |
||||
case "$1" in |
||||
start) |
||||
start |
||||
;; |
||||
stop) |
||||
stop |
||||
;; |
||||
restart|reload) |
||||
restart |
||||
;; |
||||
rebuild) |
||||
rebuild |
||||
;; |
||||
*) |
||||
echo $"Usage: $0 {start|stop|status|restart|reload}" |
||||
exit 1 |
||||
;; |
||||
esac |
||||
|
||||
exit $? |
@ -0,0 +1,44 @@ |
||||
#!/bin/bash |
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
|
||||
|
||||
action=$1 |
||||
type=$2 |
||||
|
||||
echo $action $type |
||||
|
||||
if [ "${2}" == "" ];then |
||||
echo '缺少安装脚本...' > $install_tmp |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ ! -d $curPath/versions/$2 ];then |
||||
echo '缺少安装脚本2...' > $install_tmp |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ "${action}" == "uninstall" ];then |
||||
|
||||
if [ -f /usr/lib/systemd/system/haproxy.service ] || [ -f /lib/systemd/system/haproxy.service ];then |
||||
systemctl stop haproxy |
||||
systemctl disable haproxy |
||||
rm -rf /usr/lib/systemd/system/haproxy.service |
||||
rm -rf /lib/systemd/system/haproxy.service |
||||
systemctl daemon-reload |
||||
fi |
||||
fi |
||||
|
||||
sh -x $curPath/versions/$2/install.sh $1 |
||||
|
||||
if [ "${action}" == "install" ] && [ -d $serverPath/haproxy ];then |
||||
#初始化 |
||||
cd ${rootPath} && python3 ${rootPath}/plugins/haproxy/index.py start ${type} |
||||
cd ${rootPath} && python3 ${rootPath}/plugins/haproxy/index.py initd_install ${type} |
||||
fi |
@ -0,0 +1,135 @@ |
||||
function spPostMin(method, args, callback){ |
||||
|
||||
var req_data = {}; |
||||
req_data['name'] = 'haproxy'; |
||||
req_data['func'] = method; |
||||
|
||||
if (typeof(args) != 'undefined' && args!=''){ |
||||
req_data['args'] = JSON.stringify(args); |
||||
} |
||||
|
||||
$.post('/plugins/run', req_data, function(data) { |
||||
if (!data.status){ |
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); |
||||
return; |
||||
} |
||||
|
||||
if(typeof(callback) == 'function'){ |
||||
callback(data); |
||||
} |
||||
},'json');
|
||||
} |
||||
|
||||
function spPost(method, args, callback){ |
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); |
||||
spPostMin(method,args,function(data){ |
||||
layer.close(loadT); |
||||
if(typeof(callback) == 'function'){ |
||||
callback(data); |
||||
}
|
||||
}); |
||||
} |
||||
|
||||
function rebuild(){ |
||||
var con = '<button class="btn btn-default btn-sm" onclick="rebuildIndex();">重建索引</button>'; |
||||
$(".soft-man-con").html(con); |
||||
} |
||||
|
||||
function rebuildIndex(){ |
||||
spPost('rebuild', '', function(data){ |
||||
if (data.data == 'ok'){ |
||||
layer.msg('在重建中..',{icon:1,time:2000,shade: [0.3, '#000']}); |
||||
} else { |
||||
layer.msg(data.data,{icon:2,time:2000,shade: [0.3, '#000']}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
function secToTime(s) { |
||||
var t; |
||||
if(s > -1){ |
||||
var hour = Math.floor(s/3600); |
||||
var min = Math.floor(s/60) % 60; |
||||
var sec = s % 60; |
||||
if(hour < 10) { |
||||
t = '0'+ hour + ":"; |
||||
} else { |
||||
t = hour + ":"; |
||||
} |
||||
|
||||
if(min < 10){t += "0";} |
||||
t += min + ":"; |
||||
if(sec < 10){t += "0";} |
||||
t += sec.toFixed(2); |
||||
} |
||||
return t; |
||||
} |
||||
|
||||
|
||||
function runStatus(){ |
||||
spPost('run_status', '', function(data){ |
||||
var rdata = $.parseJSON(data.data); |
||||
if (!rdata['status']){ |
||||
layer.msg(rdata['msg'],{icon:2,time:2000,shade: [0.3, '#000']}); |
||||
return; |
||||
} |
||||
var idata = rdata.data; |
||||
// console.log(idata);
|
||||
var con = '<div class="divtable"><table class="table table-hover table-bordered" style="margin-bottom:10px;background-color:#fafafa">\ |
||||
<tbody>\ |
||||
<tr><th>运行时间</th><td>' + secToTime(idata.uptime) + '</td><th>每秒查询</th><td>' + parseInt(parseInt(idata.queries) / parseInt(idata.uptime)) + '</td></tr>\ |
||||
<tr><th>总连接次数</th><td>' + idata.connections + '</td><th>work_queue_length</th><td>' +idata.work_queue_length + '</td></tr>\ |
||||
<tr><th>agent_connect</th><td>' + idata.agent_connect+ '</td><th>workers_active</th><td>' + idata.workers_active + '</td></tr>\ |
||||
<tr><th>agent_retry</th><td>' + idata.agent_retry + '</td><th>workers_total</th><td>' + idata.workers_total + '</td></tr>\ |
||||
</tbody>\ |
||||
</table>\ |
||||
<table class="table table-hover table-bordered">\ |
||||
<thead style="display:none;"><th></th><th></th><th></th><th></th></thead>\ |
||||
<tbody>\ |
||||
<tr><th>command_delete</th><td>' + idata.command_delete + '</td><td colspan="2">command_delete</td></tr>\ |
||||
<tr><th>command_excerpt</th><td>' + idata.command_excerpt + '</td><td colspan="2">command_excerpt</td></tr>\ |
||||
<tr><th>command_flushattrs</th><td>' + idata.command_flushattrs + '</td><td colspan="2">command_flushattrs</td></tr>\ |
||||
<tr><th>command_keywords</th><td>' + idata.command_keywords + '</td><td colspan="2">command_keywords</td></tr>\ |
||||
<tr><th>command_persist</th><td>' + idata.command_persist + '</td><td colspan="2">command_persist</td></tr>\ |
||||
<tr><th>command_search</th><td>' + idata.command_search + '</td><td colspan="2">command_search</td></tr>\ |
||||
<tr><th>command_status</th><td>' + idata.command_status + '</td><td colspan="2">command_status</td></tr>\ |
||||
<tr><th>command_update</th><td>' + idata.command_update + '</td><td colspan="2">command_update</td></tr>\ |
||||
<tbody>\ |
||||
</table></div>'; |
||||
|
||||
$(".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; |
||||
} |
||||
|
||||
var con = '<ul class="help-info-text c7">'; |
||||
|
||||
con += '<li style="color:red;">如果数据量比较大,第一次启动会失败!(可通过手动建立索引)</li>'; |
||||
//主索引
|
||||
for (var i = 0; i < rdata['data']['index'].length; i++) { |
||||
var index_t = rdata['data']['index'][i]; |
||||
con += '<li>主索引:' + rdata['data']['cmd'] + ' '+ index_t +' --rotate</li>'; |
||||
} |
||||
|
||||
for (var i = 0; i < rdata['data']['delta'].length; i++) { |
||||
var delta_t = rdata['data']['delta'][i]; |
||||
var list = delta_t.split(':'); |
||||
// console.log(list);
|
||||
con += '<li>增量索引:' + rdata['data']['cmd'] + ' '+ list[0] +' --rotate</li>'; |
||||
con += '<li>合并索引:' + rdata['data']['cmd'] + ' --merge '+ list[1] + ' ' + list[0] +' --rotate</li>'; |
||||
} |
||||
con += '</ul>'; |
||||
|
||||
$(".soft-man-con").html(con); |
||||
}); |
||||
|
||||
} |
||||
|
@ -0,0 +1,70 @@ |
||||
#!/bin/bash |
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
sysName=`uname` |
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
|
||||
|
||||
bash ${rootPath}/scripts/getos.sh |
||||
OSNAME=`cat ${rootPath}/data/osname.pl` |
||||
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` |
||||
|
||||
|
||||
VERSION=2.6.4 |
||||
MIN_VERSION=2.6 |
||||
Install_App() |
||||
{ |
||||
|
||||
echo '正在安装脚本文件...' > $install_tmp |
||||
mkdir -p $serverPath/haproxy |
||||
|
||||
APP_DIR=${serverPath}/source/haproxy |
||||
mkdir -p $APP_DIR |
||||
|
||||
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then |
||||
if [ $sysName == 'Darwin' ]; then |
||||
wget -O ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz |
||||
else |
||||
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz |
||||
fi |
||||
fi |
||||
|
||||
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then |
||||
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz |
||||
fi |
||||
|
||||
|
||||
cd ${APP_DIR} && tar -zxvf haproxy-${VERSION}.tar.gz |
||||
|
||||
if [ "$OSNAME" == "macos" ];then |
||||
cd ${APP_DIR}/haproxy-${VERSION} && make TARGET=osx && make install PREFIX=$serverPath/haproxy |
||||
else |
||||
cd ${APP_DIR}/haproxy-${VERSION} && make TARGET=linux-glibc && make install PREFIX=$serverPath/haproxy |
||||
fi |
||||
|
||||
echo $MIN_VERSION > $serverPath/haproxy/version.pl |
||||
echo 'Install_HA' > $install_tmp |
||||
} |
||||
|
||||
Uninstall_App() |
||||
{ |
||||
if [ -f $serverPath/haproxy/initd/haproxy ];then |
||||
$serverPath/haproxy/initd/haproxy stop |
||||
fi |
||||
|
||||
rm -rf $serverPath/haproxy |
||||
echo "Uninstall_HA" > $install_tmp |
||||
} |
||||
|
||||
action=$1 |
||||
if [ "${1}" == 'install' ];then |
||||
Install_App |
||||
else |
||||
Uninstall_App |
||||
fi |
Loading…
Reference in new issue