mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:39:25 +08:00
update
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('dynamic-tracking');">服务</p>
|
||||
<p onclick="pluginInitD('dynamic-tracking');">自启动</p>
|
||||
<p onclick="pluginLogs('dynamic-tracking','','run_log');">日志</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
@@ -13,6 +12,7 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinHeight(300);
|
||||
resetPluginWinWidth(500);
|
||||
$.getScript( "/plugins/file?name=dynamic-tracking&f=js/dynamic-tracking.js", function(){
|
||||
pluginService('dynamic-tracking', $('.plugin_version').attr('version'));
|
||||
});
|
||||
|
||||
@@ -32,16 +32,6 @@ def getInitDFile():
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/redis.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getConfTpl():
|
||||
path = getPluginDir() + "/config/redis.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
|
||||
return path
|
||||
@@ -71,66 +61,11 @@ def status():
|
||||
return 'start'
|
||||
|
||||
|
||||
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 = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# log
|
||||
dataLog = getServerDir() + '/data'
|
||||
if not os.path.exists(dataLog):
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# config replace
|
||||
dst_conf = getServerDir() + '/redis.conf'
|
||||
dst_conf_init = getServerDir() + '/init.pl'
|
||||
if not os.path.exists(dst_conf_init):
|
||||
conf_content = mw.readFile(getConfTpl())
|
||||
conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
|
||||
conf_content = conf_content.replace(
|
||||
'{$REDIS_PASS}', mw.getRandomString(10))
|
||||
|
||||
mw.writeFile(dst_conf, conf_content)
|
||||
mw.writeFile(dst_conf_init, 'ok')
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/redis.service'
|
||||
systemServiceTpl = getPluginDir() + '/init.d/redis.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')
|
||||
|
||||
return file_bin
|
||||
|
||||
|
||||
def dtOp(method):
|
||||
file = initDreplace()
|
||||
|
||||
return 'ok'
|
||||
# data = mw.execShell(file + ' start')
|
||||
# if data[1] == '':
|
||||
# return 'ok'
|
||||
# return 'fail'
|
||||
|
||||
|
||||
def start():
|
||||
|
||||
return dtOp('start')
|
||||
|
||||
|
||||
@@ -140,9 +75,6 @@ def stop():
|
||||
|
||||
def restart():
|
||||
status = dtOp('restart')
|
||||
|
||||
log_file = runLog()
|
||||
mw.execShell("echo '' > " + log_file)
|
||||
return status
|
||||
|
||||
|
||||
@@ -151,30 +83,14 @@ def reload():
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status ' + \
|
||||
getPluginName() + ' | 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 ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl disable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
{
|
||||
"hook":[
|
||||
{
|
||||
"tag":"menu",
|
||||
"menu": {
|
||||
"title":"动态追踪",
|
||||
"name":"dynamic-tracking",
|
||||
"path":"static/html/index.html",
|
||||
"css_path":"static/css/dynamic-tracking.css",
|
||||
"js_path":"static/js/dynamic-tracking.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag":"global_static",
|
||||
"global_static": {
|
||||
"title":"动态追踪",
|
||||
"name":"dynamic-tracking",
|
||||
"css_path":"static/css/ico.css"
|
||||
}
|
||||
}
|
||||
],
|
||||
"sort": 7,
|
||||
"ps": "专业使用,动态追踪调试程序<无侵入>![<span style='color:red;'>潜龙勿用|实验</span>]",
|
||||
"name": "dynamic-tracking",
|
||||
|
||||
@@ -52,15 +52,18 @@ Install_App()
|
||||
fi
|
||||
# FlameGraph end
|
||||
|
||||
shell_file=${curPath}/versions/${VERSION}/${OSNAME}.sh
|
||||
|
||||
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file
|
||||
else
|
||||
shell_file=${curPath}/versions/${OSNAME}.sh
|
||||
echo $shell_file
|
||||
if [ ! -f $shell_file ];then
|
||||
echo '不支持...' > $install_tmp
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bash -x $shell_file
|
||||
|
||||
echo "${VERSION}"
|
||||
echo "${VERSION}" > $serverPath/dynamic-tracking/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
|
||||
@@ -69,7 +72,7 @@ Install_App()
|
||||
|
||||
}
|
||||
|
||||
Uninstall_Docker()
|
||||
Uninstall_App()
|
||||
{
|
||||
rm -rf $serverPath/dynamic-tracking
|
||||
echo "Uninstall_App" > $install_tmp
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.screen-all {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.s-right .panel-default{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.s-left .panel-default{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
/* menu start */
|
||||
.menu .current .menu_dynamic-tracking:hover {
|
||||
background-image: url("/plugins/file?name=dynamic-tracking&f=ico.png");
|
||||
}
|
||||
|
||||
.menu .menu_plugin_dynamic-tracking {
|
||||
background-image: url("/plugins/file?name=dynamic-tracking&f=ico.png");
|
||||
}
|
||||
|
||||
/* menu end */
|
||||
@@ -0,0 +1,50 @@
|
||||
<style>
|
||||
.weblog{
|
||||
font-size: 12px;
|
||||
display:inline-block;
|
||||
line-height:30px;
|
||||
}
|
||||
.weblog em{
|
||||
font-style:normal;
|
||||
color:#666;
|
||||
margin: 0 30px;
|
||||
}
|
||||
.weblog span{
|
||||
margin-right:5px;
|
||||
}
|
||||
.weblog a{
|
||||
color:#20a53a;
|
||||
}
|
||||
.firewall-port-box{
|
||||
margin-bottom:15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="container-fluid" style="padding-bottom: 50px;">
|
||||
<div class="pos-box bgw mtb15">
|
||||
<div class="position f14 c9 pull-left">
|
||||
<a class="plr10 c4" href="/">首页</a>/<span class="plr10 c4">动态追踪</span>
|
||||
</div>
|
||||
|
||||
<div class="search pull-right">
|
||||
<form target="hid" onsubmit='getLogs(1,$("#SearchValue").prop("value"))'>
|
||||
<input type="text" id="SearchValue" class="ser-text pull-left" placeholder="进程ID" />
|
||||
<button type="button" class="ser-sub pull-left" onclick='getLogs(1,$("#SearchValue").prop("value"))'>采样</button>
|
||||
</form>
|
||||
<iframe name='hid' id="hid" style="display:none"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="white-black-ip bgw mtb15">
|
||||
<div class="black-ip">
|
||||
<div class="def-log">
|
||||
···
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //// -->
|
||||
</div>
|
||||
</div>
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
function redisPost(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'dynamic-tracking';
|
||||
req_data['func'] = method;
|
||||
req_data['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/run', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
//错误展示10S
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function redisPostCallbak(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'dynamic-tracking';
|
||||
req_data['func'] = method;
|
||||
args['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/callback', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
Reference in New Issue
Block a user