diff --git a/plugins/openresty/index.py b/plugins/openresty/index.py
index c52f6bd6e..ab32a5ef9 100755
--- a/plugins/openresty/index.py
+++ b/plugins/openresty/index.py
@@ -45,6 +45,11 @@ def reload():
return 'fail'
+def openrestyConf():
+ path = os.path.dirname(os.getcwd())
+ return path + "/openresty/nginx/conf/nginx.conf"
+
+
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -55,5 +60,7 @@ if __name__ == "__main__":
print stop()
elif func == 'reload':
print reload()
+ elif func == 'conf':
+ print openrestyConf()
else:
print 'error'
diff --git a/plugins/openresty/js/openresty.js b/plugins/openresty/js/openresty.js
index d74695b91..e6d38a5fe 100755
--- a/plugins/openresty/js/openresty.js
+++ b/plugins/openresty/js/openresty.js
@@ -246,9 +246,9 @@ function addWafKey(name) {
//查看Nginx负载状态
-function getStatus() {
+function getOpenrestyStatus() {
- $.post('/plugins/run', {name:'openresty', func:'run_status'}, function(data) {
+ $.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) {
console.log(data);
},'json');
$.post('/ajax?action=GetNginxStatus', '', function(rdata) {
@@ -265,136 +265,4 @@ function getStatus() {
},'json');
}
-function openrestyOp(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 setOpenrestyService(name, status){
- var serviceCon ='
当前状态:'+(status ? '开启' : '关闭' )+
- '
\
- \
- \
- \
-
';
- $(".soft-man-con").html(serviceCon);
-}
-
-//服务
-function openrestyService(){
-
- $.post('/plugins/run', {name:'openresty', 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'){
- setOpenrestyService('openresty', true);
- } else {
- setOpenrestyService('openresty', false);
- }
- },'json');
-}
-openrestyService();
-
-
-
-//配置修改 --- start
-function openrestyConfig(type){
-
- var con = '
提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!
\
-
\
-
\
- - 此处为redis主配置文件,若您不了解配置规则,请勿随意修改。
\
-
';
- $(".soft-man-con").html(con);
-
- 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",
- "Ctrl-F": "findPersistent",
- "Ctrl-H": "replaceAll",
- "Ctrl-S": function() {
- redisConfSafe(fileName);
- }
- },
- lineNumbers: true,
- matchBrackets:true,
- });
- editor.focus();
- $(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
- $("#OnlineEditFileBtn").click(function(){
- $("#textBody").text(editor.getValue());
- openrestyConfSave(fileName);
- });
- },'json');
- },'json');
-}
-
-
-//配置保存
-function openrestyConfSave(fileName) {
- var data = encodeURIComponent($("#textBody").val());
- var encoding = 'utf-8';
- var loadT = layer.msg('保存中...', {
- icon: 16,
- time: 0
- });
- $.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
- layer.close(loadT);
- layer.msg(rdata.msg, {
- icon: rdata.status ? 1 : 2
- });
- },'json');
-}
-//配置修改 --- end
+pluginService('openresty');
\ No newline at end of file
diff --git a/plugins/readme/index.py b/plugins/readme/index.py
index a0cf4103c..b496dacc5 100755
--- a/plugins/readme/index.py
+++ b/plugins/readme/index.py
@@ -7,8 +7,11 @@ import os
import urllib
import binascii
import json
-import public
import re
+import sys
+
+sys.path.append(os.getcwd() + "/class/core")
+import public
def status():
diff --git a/plugins/readme/info.json b/plugins/readme/info.json
index bb85f2f3f..2afdffc56 100755
--- a/plugins/readme/info.json
+++ b/plugins/readme/info.json
@@ -1,15 +1,15 @@
{
- "title":"插件开发说明",
+ "title":"开发说明",
"tip":"soft",
"name":"readme",
"type":"扩展",
- "ps":"(mdserver-web)插件产开发说明,每个版本可能有所变化!",
+ "ps":"[mdserver-web]插件产开发说明,每个版本可能有所变化!",
"versions": "0.1",
"shell":"install.sh",
"checks":"server/readme",
"path":"server/readme",
"author":"mdserver-web",
- "home":"github.com/midoks/mdserver-web",
+ "home":"https://github.com/midoks/mdserver-web",
"date":"2018-11-30",
"pid":"5"
}
\ No newline at end of file
diff --git a/plugins/redis/index.html b/plugins/redis/index.html
index be3a7fdbd..6d26966fa 100755
--- a/plugins/redis/index.html
+++ b/plugins/redis/index.html
@@ -12,5 +12,174 @@
\ No newline at end of file
diff --git a/plugins/redis/js/redis.js b/plugins/redis/js/redis.js
deleted file mode 100755
index 3c70f06f6..000000000
--- a/plugins/redis/js/redis.js
+++ /dev/null
@@ -1,170 +0,0 @@
-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 setRedisService(name, status){
- var serviceCon ='
当前状态:'+(status ? '开启' : '关闭' )+
- '
\
- \
- \
- \
-
';
- $(".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 = '
提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!
\
-
\
-
\
- - 此处为redis主配置文件,若您不了解配置规则,请勿随意修改。
\
-
';
- $(".soft-man-con").html(con);
-
- 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",
- "Ctrl-F": "findPersistent",
- "Ctrl-H": "replaceAll",
- "Ctrl-S": function() {
- redisConfSafe(fileName);
- }
- },
- lineNumbers: true,
- matchBrackets:true,
- });
- editor.focus();
- $(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
- $("#OnlineEditFileBtn").click(function(){
- $("#textBody").text(editor.getValue());
- redisConfSave(fileName);
- });
- },'json');
- },'json');
-}
-
-//配置保存
-function redisConfSave(fileName) {
- var data = encodeURIComponent($("#textBody").val());
- var encoding = 'utf-8';
- var loadT = layer.msg('保存中...', {
- icon: 16,
- time: 0
- });
- $.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
- layer.close(loadT);
- layer.msg(rdata.msg, {
- icon: rdata.status ? 1 : 2
- });
- },'json');
-}
-//配置修改 --- end
-
-//redis负载状态 start
-function redisStatus() {
- var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
- $.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;
- }
-
- var rdata = $.parseJSON(data.data);
- hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2);
- var Con = '
\
-
\
- 字段 | 当前值 | 说明 | \
- \
- uptime_in_days | ' + rdata.uptime_in_days + ' | 已运行天数 |
\
- tcp_port | ' + rdata.tcp_port + ' | 当前监听端口 |
\
- connected_clients | ' + rdata.connected_clients + ' | 连接的客户端数量 |
\
- used_memory_rss | ' + toSize(rdata.used_memory_rss) + ' | Redis当前占用的系统内存总量 |
\
- used_memory | ' + toSize(rdata.used_memory) + ' | Redis当前已分配的内存总量 |
\
- used_memory_peak | ' + toSize(rdata.used_memory_peak) + ' | Redis历史分配内存的峰值 |
\
- mem_fragmentation_ratio | ' + rdata.mem_fragmentation_ratio + '% | 内存碎片比率 |
\
- total_connections_received | ' + rdata.total_connections_received + ' | 运行以来连接过的客户端的总数量 |
\
- total_commands_processed | ' + rdata.total_commands_processed + ' | 运行以来执行过的命令的总数量 |
\
- instantaneous_ops_per_sec | ' + rdata.instantaneous_ops_per_sec + ' | 服务器每秒钟执行的命令数量 |
\
- keyspace_hits | ' + rdata.keyspace_hits + ' | 查找数据库键成功的次数 |
\
- keyspace_misses | ' + rdata.keyspace_misses + ' | 查找数据库键失败的次数 |
\
- hit | ' + hit + '% | 查找数据库键命中率 |
\
- latest_fork_usec | ' + rdata.latest_fork_usec + ' | 最近一次 fork() 操作耗费的微秒数 |
\
- \
-
'
- $(".soft-man-con").html(Con);
- },'json');
-}
-//redis负载状态 end
\ No newline at end of file
diff --git a/plugins/score/index.py b/plugins/score/index.py
index a94a2b101..3a1db22b1 100755
--- a/plugins/score/index.py
+++ b/plugins/score/index.py
@@ -7,8 +7,11 @@ import os
import urllib
import binascii
import json
-import public
import re
+import sys
+
+sys.path.append(os.getcwd() + "/class/core")
+import public
class score_main:
diff --git a/route/plugins.py b/route/plugins.py
index 8957818cc..6c9e1279b 100644
--- a/route/plugins.py
+++ b/route/plugins.py
@@ -179,18 +179,11 @@ def setting():
def run():
name = request.form.get('name', '')
func = request.form.get('func', '')
+ version = request.form.get('version', '')
args = request.form.get('args', '')
script = request.form.get('script', 'index')
- py = 'python ' + public.getRunDir() + '/' + __plugin_name + '/' + name
- if args == '':
- py = py + '/' + script + '.py' + ' ' + func
- else:
- py = py + '/' + script + '.py' + ' ' + func + ' ' + args
-
- print py
- data = public.execShell(py)
-
- if data[1].strip() == '':
+ data = plugin_api.plugin_api().run(name, func, version, args, script)
+ if data[1] == '':
return public.returnJson(True, "OK", data[0].strip())
return public.returnJson(False, data[1].strip())
diff --git a/static/app/public.js b/static/app/public.js
index 80e266aa6..7609ae160 100755
--- a/static/app/public.js
+++ b/static/app/public.js
@@ -1473,20 +1473,129 @@ $(function(){
/*** 其中功能,针对插件通过库使用 start ***/
function pluginService(_name){
$.post('/plugins/run', {name:_name, 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'){
- setOpenrestyService('openresty', true);
+ pluginSetService(_name, true);
} else {
- setOpenrestyService('openresty', false);
+ pluginSetService(_name, false);
}
},'json');
}
-function pluginSetService(_name ,start){
+function pluginSetService(_name ,status){
+ var serviceCon ='
当前状态:'+(status ? '开启' : '关闭' )+
+ '
\
+ \
+ \
+ \
+
';
+ $(".soft-man-con").html(serviceCon);
+}
+
+
+function pluginOpService(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') {
+ pluginSetService(a, true);
+ } else if (b=='stop'){
+ pluginSetService(a, 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});
+ });
+ })
+}
+
+//配置修改 --- start
+function pluginConfig(_name){
+
+ var con = '
提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!
\
+
\
+
\
+ - 此处为'+ _name +'主配置文件,若您不了解配置规则,请勿随意修改。
\
+
';
+ $(".soft-man-con").html(con);
+
+ var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
+ $.post('/plugins/run', {name:_name, 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",
+ "Ctrl-F": "findPersistent",
+ "Ctrl-H": "replaceAll",
+ "Ctrl-S": function() {
+ pluginConfigSave(fileName);
+ }
+ },
+ lineNumbers: true,
+ matchBrackets:true,
+ });
+ editor.focus();
+ $(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
+ $("#OnlineEditFileBtn").click(function(){
+ $("#textBody").text(editor.getValue());
+ pluginConfigSave(fileName);
+ });
+ },'json');
+ },'json');
+}
+
+
+//配置保存
+function pluginConfigSave(fileName) {
+ var data = encodeURIComponent($("#textBody").val());
+ var encoding = 'utf-8';
+ var loadT = layer.msg('保存中...', {
+ icon: 16,
+ time: 0
+ });
+ $.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
+ layer.close(loadT);
+ layer.msg(rdata.msg, {
+ icon: rdata.status ? 1 : 2
+ });
+ },'json');
}
/*** 其中功能,针对插件通过库使用 end ***/
\ No newline at end of file