|
|
|
@ -1,24 +1,83 @@ |
|
|
|
|
function redisOp(a, b) { |
|
|
|
|
|
|
|
|
|
var c = "name=" + a + "&func=" + b; |
|
|
|
|
var d = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(b) { |
|
|
|
|
case "stop": |
|
|
|
|
d = '停止'; |
|
|
|
|
break; |
|
|
|
|
case "start": |
|
|
|
|
d = '启动'; |
|
|
|
|
break; |
|
|
|
|
case "restart": |
|
|
|
|
d = '重启'; |
|
|
|
|
break; |
|
|
|
|
case "reload": |
|
|
|
|
d = '重载'; |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
layer.confirm( '您真的要{1}{2}服务吗?'.replace('{1}', d).replace('{2}', a), {icon:3,closeBtn: 2}, function() { |
|
|
|
|
var e = layer.msg('正在{1}{2}服务,请稍候...'.replace('{1}', d).replace('{2}', a), {icon: 16,time: 0}); |
|
|
|
|
$.post("/plugins/run", c, function(g) { |
|
|
|
|
layer.close(e); |
|
|
|
|
|
|
|
|
|
var f = g.data == 'ok' ? '{1}服务已{2}'.replace('{1}', a).replace('{2}', d):'{1}服务{2}失败!'.replace('{1}', a).replace('{2}', d); |
|
|
|
|
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2}); |
|
|
|
|
|
|
|
|
|
if(b != "reload" && g.data == 'ok') { |
|
|
|
|
if (b == 'start') { |
|
|
|
|
setRedisService('redis', true); |
|
|
|
|
} else if (b=='stop'){ |
|
|
|
|
setRedisService('redis', false); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(g.data != 'ok') { |
|
|
|
|
layer.msg(g.data, {icon: 2,time: 0,shade: 0.3,shadeClose: true}); |
|
|
|
|
} |
|
|
|
|
},'json').error(function() { |
|
|
|
|
layer.close(e); |
|
|
|
|
layer.msg('操作成功!', {icon: 1}); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//服务
|
|
|
|
|
function redisService(){ |
|
|
|
|
var status = false; |
|
|
|
|
var name = 'redis'; |
|
|
|
|
|
|
|
|
|
function setRedisService(name, status){ |
|
|
|
|
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '开启' : '关闭' )+ |
|
|
|
|
'</span><span style="color: '+ |
|
|
|
|
(status?'#20a53a;':'red;')+ |
|
|
|
|
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\ |
|
|
|
|
<button class="btn btn-default btn-sm" onclick="ServiceAdmin(\''+name+'\',\''+(status?'stop':'start')+'\')">'+(status?'停止':'启动')+'</button>\ |
|
|
|
|
<button class="btn btn-default btn-sm" onclick="ServiceAdmin(\''+name+'\',\'restart\')">重启</button>\ |
|
|
|
|
<button class="btn btn-default btn-sm" onclick="ServiceAdmin(\''+name+'\',\'reload\')">重载配置</button>\ |
|
|
|
|
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\''+(status?'stop':'start')+'\')">'+(status?'停止':'启动')+'</button>\ |
|
|
|
|
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\'restart\')">重启</button>\ |
|
|
|
|
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\'reload\')">重载配置</button>\ |
|
|
|
|
</div>'; |
|
|
|
|
$(".soft-man-con").html(serviceCon); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//配置修改
|
|
|
|
|
|
|
|
|
|
//服务
|
|
|
|
|
function redisService(){ |
|
|
|
|
|
|
|
|
|
$.post('/plugins/run', {name:'redis', func:'status'}, function(data) { |
|
|
|
|
console.log(data); |
|
|
|
|
if(!data.status){ |
|
|
|
|
layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (data.data == 'start'){ |
|
|
|
|
setRedisService('redis', true); |
|
|
|
|
} else { |
|
|
|
|
setRedisService('redis', false); |
|
|
|
|
} |
|
|
|
|
},'json'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
redisService(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//配置修改 --- start
|
|
|
|
|
function redisConfig(type){ |
|
|
|
|
|
|
|
|
|
var con = '<p style="color: #666; margin-bottom: 7px">提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!</p><textarea class="bt-input-text" style="height: 320px; line-height:18px;" id="textBody"></textarea>\ |
|
|
|
@ -31,14 +90,26 @@ function redisConfig(type){ |
|
|
|
|
var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']}); |
|
|
|
|
$.post('/plugins/run', {name:'redis', func:'conf'},function (data) { |
|
|
|
|
layer.close(loadT); |
|
|
|
|
|
|
|
|
|
var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']}); |
|
|
|
|
var fileName = data.data; |
|
|
|
|
$.post('/files/get_body', 'path=' + fileName, function(rdata) { |
|
|
|
|
layer.close(loadT2); |
|
|
|
|
if (!rdata.status){ |
|
|
|
|
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$("#textBody").empty().text(rdata.data.data); |
|
|
|
|
$(".CodeMirror").remove(); |
|
|
|
|
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), { |
|
|
|
|
extraKeys: {"Ctrl-Space": "autocomplete"}, |
|
|
|
|
extraKeys: { |
|
|
|
|
"Ctrl-Space": "autocomplete", |
|
|
|
|
"Ctrl-F": "findPersistent", |
|
|
|
|
"Ctrl-H": "replaceAll", |
|
|
|
|
"Ctrl-S": function() { |
|
|
|
|
redisConfSafe(fileName); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
lineNumbers: true, |
|
|
|
|
matchBrackets:true, |
|
|
|
|
}); |
|
|
|
@ -67,14 +138,15 @@ function redisConfSafe(fileName) { |
|
|
|
|
}); |
|
|
|
|
},'json'); |
|
|
|
|
} |
|
|
|
|
//配置修改 --- end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//redis负载状态
|
|
|
|
|
//redis负载状态 start
|
|
|
|
|
function redisStatus() { |
|
|
|
|
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); |
|
|
|
|
$.post('/plugins/run', {name:'redis', func:'status'}, function(data) { |
|
|
|
|
$.post('/plugins/run', {name:'redis', func:'run_info'}, function(data) { |
|
|
|
|
layer.close(loadT); |
|
|
|
|
if (!data.status){ |
|
|
|
|
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -103,5 +175,4 @@ function redisStatus() { |
|
|
|
|
$(".soft-man-con").html(Con); |
|
|
|
|
},'json'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
redisService(); |
|
|
|
|
//redis负载状态 end
|