parent
5b73b73f16
commit
7cf2d6ab11
|
|
@ -112,4 +112,3 @@ data/json/index.json
|
|||
*.zip
|
||||
data/*.db
|
||||
data/control.conf
|
||||
plugins/memcached/init.d/memcached
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('memcached');">服务</p>
|
||||
<p onclick="pluginInitD('memcached');">自启动</p>
|
||||
<p onclick="pluginConfig('memcached');">配置修改</p>
|
||||
<p onclick="memcachedStatus();">负载状态</p>
|
||||
<p onclick="memcachedCache();">性能调整</p>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import time
|
|||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getAppName():
|
||||
return 'memcached'
|
||||
|
|
@ -21,6 +23,12 @@ def getServerDir():
|
|||
return public.getServerDir() + '/' + getAppName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
if app_debug:
|
||||
return '/tmp/' + getAppName()
|
||||
return '/etc/init.d/' + getAppName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getPluginDir() + "/init.d/memcached.tpl"
|
||||
return path
|
||||
|
|
@ -37,7 +45,7 @@ def getArgs():
|
|||
|
||||
def status():
|
||||
data = public.execShell(
|
||||
"ps -ef|grep memcached |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
"ps -ef|grep " + getAppName() + " |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
|
@ -155,15 +163,43 @@ def saveConf():
|
|||
return 'fail'
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
if os.path.exists(initd_bin):
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mem_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(mem_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'run_info':
|
||||
print runInfo()
|
||||
elif func == 'conf':
|
||||
print getConf()
|
||||
elif func == 'save_conf':
|
||||
print saveConf()
|
||||
elif func == 'status':
|
||||
if func == 'status':
|
||||
print status()
|
||||
elif func == 'start':
|
||||
print start()
|
||||
|
|
@ -173,5 +209,17 @@ if __name__ == "__main__":
|
|||
print restart()
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
elif func == 'initd_status':
|
||||
print initdStatus()
|
||||
elif func == 'initd_install':
|
||||
print initdInstall()
|
||||
elif func == 'initd_uninstall':
|
||||
print initdUinstall()
|
||||
elif func == 'run_info':
|
||||
print runInfo()
|
||||
elif func == 'conf':
|
||||
print getConf()
|
||||
elif func == 'save_conf':
|
||||
print saveConf()
|
||||
else:
|
||||
print 'fail'
|
||||
|
|
|
|||
|
|
@ -1623,4 +1623,58 @@ function pluginConfigSave(fileName) {
|
|||
});
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
function pluginInitD(_name){
|
||||
$.post('/plugins/run', {name:_name, func:'initd_status'}, function(data) {
|
||||
if(!data.status || (data.data!='ok' && data.data!='fail') ){
|
||||
layer.msg(data.data,{icon:0,time:3000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
if (data.data == 'ok'){
|
||||
pluginSetInitD(_name, true);
|
||||
} else {
|
||||
pluginSetInitD(_name, false);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function pluginSetInitD(_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="pluginOpInitD(\''+_name+'\',\''+(status?'initd_uninstall':'initd_install')+'\')">'+(status?'卸载':'加载')+'</button>\
|
||||
</div>';
|
||||
$(".soft-man-con").html(serviceCon);
|
||||
}
|
||||
|
||||
function pluginOpInitD(a, b) {
|
||||
var c = "name=" + a + "&func=" + b;
|
||||
var d = "";
|
||||
switch(b) {
|
||||
case "initd_install":d = '加载';break;
|
||||
case "initd_uninstall":d = '卸载';break;
|
||||
}
|
||||
layer.confirm( msgTpl('您真的要{1}{2}服务吗?', [d,a]), {icon:3,closeBtn: 2}, function() {
|
||||
var e = layer.msg(msgTpl('正在{1}{2}服务,请稍候...',[d,a]), {icon: 16,time: 0});
|
||||
$.post("/plugins/run", c, function(g) {
|
||||
layer.close(e);
|
||||
var f = g.data == 'ok' ? msgTpl('{1}服务已{2}',[a,d]) : msgTpl('{1}服务{2}失败!',[a,d]);
|
||||
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
|
||||
|
||||
if ( b == 'initd_install' && g.data == 'ok' ) {
|
||||
pluginSetInitD(a, true);
|
||||
}else{
|
||||
pluginSetInitD(a, false);
|
||||
}
|
||||
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: 0});
|
||||
});
|
||||
})
|
||||
}
|
||||
/*** 其中功能,针对插件通过库使用 end ***/
|
||||
Loading…
Reference in New Issue