From 6954bb947e644e450e5b347df23ddedee7580fa3 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Thu, 13 Jun 2024 23:29:25 +0800 Subject: [PATCH] update --- plugins/php-yum/conf/app_start.php | 53 ++++++++++++++++++++++++++++++ plugins/php-yum/conf/php-fpm.conf | 5 +++ plugins/php-yum/index.py | 20 +++++++++-- plugins/php-yum/install.sh | 10 ++++++ plugins/php-yum/js/php.js | 6 ++++ 5 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 plugins/php-yum/conf/app_start.php create mode 100644 plugins/php-yum/conf/php-fpm.conf diff --git a/plugins/php-yum/conf/app_start.php b/plugins/php-yum/conf/app_start.php new file mode 100644 index 000000000..8a21a7cd4 --- /dev/null +++ b/plugins/php-yum/conf/app_start.php @@ -0,0 +1,53 @@ +save_run($xhprof_data, 'xhprof_foo'); + + $profiler_url = sprintf('http://{$LOCAL_IP}:5858/index.php?run=%s&source=xhprof_foo', $run_id); + echo ""; + // echo 'Profiler output'; + +} + +if (extension_loaded('xhprof') + && isset($_GET[XHProf_Name]) && $_GET[XHProf_Name] == 'ok' && + (!in_array($_SERVER['SCRIPT_NAME'], array('/xhprof_html/callgraph.php', + '/xhprof_html/index.php')))) { + app_xhprof_start(); + include_once $_SERVER['SCRIPT_FILENAME']; + app_xhprof_end(); + exit; +} + +?> diff --git a/plugins/php-yum/conf/php-fpm.conf b/plugins/php-yum/conf/php-fpm.conf new file mode 100644 index 000000000..aeee58e60 --- /dev/null +++ b/plugins/php-yum/conf/php-fpm.conf @@ -0,0 +1,5 @@ +[global] +pid = /run/php/php{$PHP_VERSION}-fpm.pid +error_log = /var/log/php{$PHP_VERSION}-fpm.log +include=/etc/php/{$PHP_VERSION}/fpm/pool.d/*.conf +php_value[auto_prepend_file]={$SERVER_PATH}/php-apt/app_start.php \ No newline at end of file diff --git a/plugins/php-yum/index.py b/plugins/php-yum/index.py index cab7d6d74..4fdefad52 100755 --- a/plugins/php-yum/index.py +++ b/plugins/php-yum/index.py @@ -27,6 +27,9 @@ def getPluginName(): return 'php-yum' +def getAppDir(): + return mw.getServerDir()+'/'+getPluginName() + def getServerDir(): return '/etc/opt/remi' @@ -157,11 +160,22 @@ def phpFpmWwwReplace(version): content = contentReplace(content, version) mw.writeFile(service_php_fpm_mw, content) +def phpPrependFile(version): + app_start = getAppDir() + '/app_start.php' + if not os.path.exists(app_start): + tpl = getPluginDir() + '/conf/app_start.php' + content = mw.readFile(tpl) + content = contentReplace(content, version) + mw.writeFile(app_start, content) def getFpmConfFile(version): return getServerDir() + '/php' + version + '/php-fpm.d/mw.conf' +def getFpmFile(version): + return getServerDir() + '/php' + version + '/php-fpm.conf' + + def deleteConfList(version): sdir = mw.getServerDir() enable_conf = sdir + '/web_conf/php/conf/enable-php-yum' + version + '.conf' @@ -176,7 +190,7 @@ def initReplace(version): makeOpenrestyConf(version) phpFpmWwwReplace(version) - install_ok = getServerDir() + "/" + version + "/install.ok" + install_ok = getAppDir() + "/" + version + "/install.ok" if not os.path.exists(install_ok): phpini = getConf(version) ssl_crt = mw.getSslCrt() @@ -187,6 +201,7 @@ def initReplace(version): mw.execShell(cmd_curl) mw.writeFile(install_ok, 'ok') + phpPrependFile(version) # systemd # mw.execShell('systemctl daemon-reload') return 'ok' @@ -227,8 +242,7 @@ def initdStatus(version): if mw.isAppleSystem(): return "Apple Computer does not support" - shell_cmd = 'systemctl status php' + version + \ - '-php-fpm | grep loaded | grep "enabled;"' + shell_cmd = 'systemctl status php' + version + '-php-fpm | grep loaded | grep "enabled;"' data = mw.execShell(shell_cmd) if data[0] == '': return 'fail' diff --git a/plugins/php-yum/install.sh b/plugins/php-yum/install.sh index 33ed4be70..466713052 100755 --- a/plugins/php-yum/install.sh +++ b/plugins/php-yum/install.sh @@ -56,6 +56,16 @@ if [ "${action}" == "uninstall" ] && [ -d ${serverPath}/php-yum/${type} ];then #初始化 cd ${rootPath} && python3 ${rootPath}/plugins/php-yum/index.py stop ${type} cd ${rootPath} && python3 ${rootPath}/plugins/php-yum/index.py initd_uninstall ${type} + + if [ -f /lib/systemd/system/php${type}-php-fpm.service ];then + rm -rf /lib/systemd/system/php${type}-fpm.service + fi + + if [ -f /lib/systemd/system/system/php${type}-php-fpm.service ];then + rm -rf /lib/systemd/system/php${type}-php-fpm.service + fi + + systemctl daemon-reload fi cd ${curPath} && sh -x $curPath/versions/$2/install.sh $1 diff --git a/plugins/php-yum/js/php.js b/plugins/php-yum/js/php.js index 8b53aa565..8e13b693c 100755 --- a/plugins/php-yum/js/php.js +++ b/plugins/php-yum/js/php.js @@ -184,6 +184,12 @@ function phpOpcacheBlacklist(version){ }); } +function phpFpmRoot(version){ + phpPost('get_fpm_file',version,{},function(data){ + onlineEditFile(0, data['data']); + }); +} + function getFpmConfig(version){ phpPost('get_fpm_conf', version, {}, function(data){