From ada8225e059c960f694cfedd31be3c2e41a694fa Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 15 Mar 2019 15:23:54 +0800 Subject: [PATCH] update --- class/core/config_api.py | 3 ++- plugins/php/index.html | 2 +- plugins/php/index.py | 45 ++++++++++++++++++++++++++++++++++++-- plugins/php/init.d/php.tpl | 2 ++ route/static/app/public.js | 30 ++++++++++++++----------- 5 files changed, 65 insertions(+), 17 deletions(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index a418db113..9ad508b4a 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -17,7 +17,8 @@ class config_api: # 本版解决自启动问题 # openresty 自启动 done - __version = '0.5.0' + # php 自动 done + __version = '0.5.2' def __init__(self): pass diff --git a/plugins/php/index.html b/plugins/php/index.html index e7aa1d6db..2243a9543 100755 --- a/plugins/php/index.html +++ b/plugins/php/index.html @@ -3,6 +3,7 @@

服务

+

自启动

安装扩展

配置修改

上传限制

@@ -25,5 +26,4 @@ $.getScript( "/plugins/file?name=php&f=js/php.js", function(){ pluginService('php', $('.plugin_version').attr('version')); }); - \ No newline at end of file diff --git a/plugins/php/index.py b/plugins/php/index.py index e313f39bf..56d3d30bb 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -33,10 +33,10 @@ def getServerDir(): return public.getServerDir() + '/' + getPluginName() -def getInitDFile(): +def getInitDFile(version): if app_debug: return '/tmp/' + getPluginName() - return '/etc/init.d/' + getPluginName() + return '/etc/init.d/' + getPluginName()+version def getArgs(): @@ -216,6 +216,41 @@ def reload(version): return phpOp(version, 'reload') +def initdStatus(version): + if not app_debug: + if public.isAppleSystem(): + return "Apple Computer does not support" + initd_bin = getInitDFile(version) + if os.path.exists(initd_bin): + return 'ok' + return 'fail' + + +def initdInstall(version): + import shutil + if not app_debug: + if public.isAppleSystem(): + return "Apple Computer does not support" + + source_bin = initReplace(version) + initd_bin = getInitDFile(version) + shutil.copyfile(source_bin, initd_bin) + public.execShell('chmod +x ' + initd_bin) + public.execShell('chkconfig --add ' + getPluginName()+version) + return 'ok' + + +def initdUinstall(version): + if not app_debug: + if public.isAppleSystem(): + return "Apple Computer does not support" + + public.execShell('chkconfig --del ' + getPluginName()) + initd_bin = getInitDFile(version) + os.remove(initd_bin) + return 'ok' + + def fpmLog(version): return getServerDir() + '/' + version + '/var/log/php-fpm.log' @@ -595,6 +630,12 @@ if __name__ == "__main__": print restart(version) elif func == 'reload': print reload(version) + elif func == 'initd_status': + print initdStatus(version) + elif func == 'initd_install': + print initdInstall(version) + elif func == 'initd_uninstall': + print initdUinstall(version) elif func == 'fpm_log': print fpmLog(version) elif func == 'fpm_slow_log': diff --git a/plugins/php/init.d/php.tpl b/plugins/php/init.d/php.tpl index 90b82b840..bbf46fddd 100644 --- a/plugins/php/init.d/php.tpl +++ b/plugins/php/init.d/php.tpl @@ -1,4 +1,6 @@ #! /bin/sh +# chkconfig: 2345 55 25 +# description: PHP Service ### BEGIN INIT INFO # Provides: php-fpm diff --git a/route/static/app/public.js b/route/static/app/public.js index 2a860c97a..3ec256472 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -1773,9 +1773,13 @@ function pluginConfigSave(fileName) { } -function pluginInitD(_name){ + +function pluginInitD(_name,_version){ + if (typeof _version == 'undefined'){ + _version = ''; + } var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); - $.post('/plugins/run', {name:_name, func:'initd_status'}, function(data) { + $.post('/plugins/run', {name:_name, func:'initd_status',version : _version}, function(data) { layer.close(loadT); if( !data.status ){ layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']}); @@ -1786,41 +1790,41 @@ function pluginInitD(_name){ return; } if (data.data == 'ok'){ - pluginSetInitD(_name, true); + pluginSetInitD(_name, _version, true); } else { - pluginSetInitD(_name, false); + pluginSetInitD(_name, _version, false); } },'json'); } -function pluginSetInitD(_name, status){ +function pluginSetInitD(_name, _version, status){ var serviceCon ='

当前状态:'+(status ? '已加载' : '未加载' )+ '

\ - \ + \
'; $(".soft-man-con").html(serviceCon); } -function pluginOpInitD(a, b) { - var c = "name=" + a + "&func=" + b; +function pluginOpInitD(a, _version, b) { + var c = "name=" + a + "&func=" + b + "&version="+_version; 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}); + layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,_version]), {icon:3,closeBtn: 2}, function() { + var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,_version]), {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]); + var f = g.data == 'ok' ? msgTpl('{1}{3}服务已{2}',[a,d,_version]) : msgTpl('{1}{3}服务{2}失败!',[a,d,_version]); layer.msg(f, {icon: g.data == 'ok' ? 1 : 2}); if ( b == 'initd_install' && g.data == 'ok' ) { - pluginSetInitD(a, true); + pluginSetInitD(a, _version, true); }else{ - pluginSetInitD(a, false); + pluginSetInitD(a, _version, false); } if(g.data != 'ok') { layer.msg(g.data, {icon: 2,time: 0,shade: 0.3,shadeClose: true});