Merge pull request #7 from midoks/dev

merge
pull/109/head
xcsoft 3 years ago committed by GitHub
commit c59f27859a
  1. 2
      LICENSE
  2. 17
      class/core/mw.py
  3. 7
      class/core/plugins_api.py
  4. 6
      class/core/site_api.py
  5. 16
      plugins/openresty/index.py
  6. 13
      plugins/openresty/install.sh
  7. 31
      plugins/php/index.py
  8. 2
      plugins/php/lib/zlib.sh
  9. 40
      plugins/php/versions/52/install.sh
  10. 3
      plugins/redis/index.py
  11. 1
      plugins/varnish/index.html
  12. 6
      plugins/varnish/index.py
  13. 61
      plugins/varnish/js/varnish.js
  14. 2
      requirements.txt
  15. 8
      route/static/app/soft.js
  16. 47
      scripts/install/debian.sh
  17. 2
      scripts/install/ubuntu.sh
  18. 1
      scripts/install_dev.sh
  19. 9
      scripts/lib.sh
  20. 1
      scripts/update/debian.sh
  21. 74
      task.py

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright [yyyy] [name of copyright owner] Copyright [midoks] [midoks of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -98,6 +98,23 @@ def isAppleSystem():
return False return False
def isNumber(s):
try:
float(s)
return True
except ValueError:
pass
try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError, ValueError):
pass
return False
def deleteFile(file): def deleteFile(file):
if os.path.exists(file): if os.path.exists(file):
os.remove(file) os.remove(file)

@ -48,6 +48,13 @@ class plugins_api:
def listApi(self): def listApi(self):
sType = request.args.get('type', '0') sType = request.args.get('type', '0')
sPage = request.args.get('p', '1') sPage = request.args.get('p', '1')
if not mw.isNumber(sPage):
sPage = 1
if not mw.isNumber(sType):
sType = 0
# print sPage # print sPage
data = self.getPluginList(sType, int(sPage)) data = self.getPluginList(sType, int(sPage))
return mw.getJson(data) return mw.getJson(data)

@ -599,7 +599,11 @@ class site_api:
if not os.path.exists(acem): if not os.path.exists(acem):
return mw.returnJson(False, '尝试自动安装ACME失败,请通过以下命令尝试手动安装<p>安装命令: curl https://get.acme.sh | sh</p>' + acem) return mw.returnJson(False, '尝试自动安装ACME失败,请通过以下命令尝试手动安装<p>安装命令: curl https://get.acme.sh | sh</p>' + acem)
force_bool = False # 避免频繁执行
checkAcmeRun = mw.execShell('ps -ef|grep acme.sh |grep -v grep')
if checkAcmeRun[0] != '':
return mw.returnJson(False, '正在申请或更新SSL中...')
if force == 'true': if force == 'true':
force_bool = True force_bool = True

@ -267,7 +267,21 @@ def initdUinstall():
def runInfo(): def runInfo():
# 取Openresty负载状态 # 取Openresty负载状态
try: try:
result = mw.httpGet('http://127.0.0.1/nginx_status') url = 'http://' + mw.getHostAddr() + '/nginx_status'
result = mw.httpGet(url)
tmp = result.split()
data = {}
data['active'] = tmp[2]
data['accepts'] = tmp[9]
data['handled'] = tmp[7]
data['requests'] = tmp[8]
data['Reading'] = tmp[11]
data['Writing'] = tmp[13]
data['Waiting'] = tmp[15]
return mw.getJson(data)
except Exception as e:
url = 'http://127.0.0.1/nginx_status'
result = mw.httpGet(url)
tmp = result.split() tmp = result.split()
data = {} data = {}
data['active'] = tmp[2] data['active'] = tmp[2]

@ -24,6 +24,7 @@ else
useradd -g www -s /bin/bash www useradd -g www -s /bin/bash www
fi fi
# cd /www/server/mdserver-web/plugins/openresty && /bin/bash install.sh install 1.21.4.1
Install_openresty() Install_openresty()
{ {
mkdir -p ${openrestyDir} mkdir -p ${openrestyDir}
@ -37,13 +38,19 @@ Install_openresty()
cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz
# --with-openssl=$serverPath/source/lib/openssl-1.0.2q # --with-openssl=$serverPath/source/lib/openssl-1.0.2q
cd ${openrestyDir}/openresty-${VERSION} && ./configure --prefix=$serverPath/openresty \ cd ${openrestyDir}/openresty-${VERSION} && ./configure \
--prefix=$serverPath/openresty \
--with-http_v2_module \ --with-http_v2_module \
--with-http_ssl_module \ --with-http_ssl_module \
--with-http_slice_module \ --with-http_slice_module \
--with-http_stub_status_module && make && make install && \ --with-http_stub_status_module
gmake && gmake install && make clean
if [ -d $serverPath/openresty ];then
echo "${VERSION}" > $serverPath/openresty/version.pl echo "${VERSION}" > $serverPath/openresty/version.pl
echo "" > $serverPath/web_conf/nginx/enable-php-00.conf echo "" > $serverPath/openresty/nginx/conf/enable-php-00.conf
fi
echo '安装完成' > $install_tmp echo '安装完成' > $install_tmp
} }

@ -521,25 +521,38 @@ def setFpmConfig(version):
def checkFpmStatusFile(version): def checkFpmStatusFile(version):
if mw.isInstalledWeb(): if not mw.isInstalledWeb():
sdir = mw.getServerDir() return False
dfile = sdir + '/openresty/nginx/conf/php_status/phpfpm_status_' + version + '.conf'
dfile = getServerDir() + '/nginx/conf/php_status/phpfpm_status_' + version + '.conf'
if not os.path.exists(dfile): if not os.path.exists(dfile):
tpl = getPluginDir() + '/conf/phpfpm_status.conf' tpl = getPluginDir() + '/conf/phpfpm_status.conf'
content = mw.readFile(tpl) content = mw.readFile(tpl)
content = contentReplace(content, version) content = contentReplace(content, version)
mw.writeFile(dfile, content) mw.writeFile(dfile, content)
mw.restartWeb() mw.restartWeb()
return True
def getFpmStatus(version): def getFpmStatus(version):
checkFpmStatusFile(version) checkFpmStatusFile(version)
result = mw.httpGet(
'http://127.0.0.1/phpfpm_status_' + version + '?json') try:
tmp = json.loads(result) url = 'http://' + mw.getHostAddr() + '/phpfpm_status_' + version + '?json'
fTime = time.localtime(int(tmp['start time'])) result = mw.httpGet(url)
tmp['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime) data = json.loads(result)
return mw.getJson(tmp) fTime = time.localtime(int(data['start time']))
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)
except Exception as e:
url = 'http://127.0.0.1/phpfpm_status_' + version + '?json'
result = mw.httpGet(url)
data = json.loads(result)
fTime = time.localtime(int(data['start time']))
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)
except Exception as e:
data = {}
return mw.getJson(data)
def getDisableFunc(version): def getDisableFunc(version):

@ -13,7 +13,7 @@ rootPath=$(dirname "$rootPath")
SERVER_ROOT=$rootPath/lib SERVER_ROOT=$rootPath/lib
SOURCE_ROOT=$rootPath/source/lib SOURCE_ROOT=$rootPath/source/lib
if [ ! -d ${SERVER_ROOT}/libiconv ];then if [ ! -d ${SERVER_ROOT}/zlib ];then
cd $SOURCE_ROOT cd $SOURCE_ROOT
if [ ! -f ${SOURCE_ROOT}/zlib-1.2.11.tar.gz ];then if [ ! -f ${SOURCE_ROOT}/zlib-1.2.11.tar.gz ];then

@ -11,6 +11,46 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl install_tmp=${rootPath}/tmp/mw_install.pl
_os=`uname`
echo "use system: ${_os}"
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
OSNAME='rocky'
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
OSNAME='alma'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
else
OSNAME='unknow'
fi
if [ "$OSNAME" == 'ubuntu' ] || [ "$OSNAME" == 'debian' ] ;then
apt install bison=2.4.1
if [ "$?" != "0" ]; then
echo 'The system version is too high to install'
exit 1
fi
apt install flex=2.5.4
if [ "$?" != "0" ]; then
echo 'The system version is too high to install'
exit 1
fi
fi
version=5.2.17 version=5.2.17
PHP_VER=52 PHP_VER=52
Install_php() Install_php()

@ -96,9 +96,12 @@ def initDreplace():
# config replace # config replace
dst_conf = getServerDir() + '/redis.conf' 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 = mw.readFile(getConfTpl())
conf_content = conf_content.replace('{$SERVER_PATH}', service_path) conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(dst_conf, conf_content) mw.writeFile(dst_conf, conf_content)
mw.writeFile(dst_conf_init, 'ok')
# systemd # systemd
systemDir = '/lib/systemd/system' systemDir = '/lib/systemd/system'

@ -4,6 +4,7 @@
<p class="bgw" onclick="pluginService('varnish');">服务</p> <p class="bgw" onclick="pluginService('varnish');">服务</p>
<p onclick="pluginInitD('varnish');">自启动</p> <p onclick="pluginInitD('varnish');">自启动</p>
<p onclick="pluginConfigTpl('varnish');">VCL</p> <p onclick="pluginConfigTpl('varnish');">VCL</p>
<p onclick="varnishPluginConfig('varnish','','conf_service');">服务配置</p>
<p onclick="pluginLogs('varnish','','run_log');">日志</p> <p onclick="pluginLogs('varnish','','run_log');">日志</p>
<p onclick="varnishStatus();">状态</p> <p onclick="varnishStatus();">状态</p>
</div> </div>

@ -172,6 +172,10 @@ def initdUinstall():
def runLog(): def runLog():
return "/var/log/varnish/varnishncsa.log" return "/var/log/varnish/varnishncsa.log"
def confService():
return '/lib/systemd/system/varnish.service'
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
if func == 'status': if func == 'status':
@ -194,6 +198,8 @@ if __name__ == "__main__":
print(runInfo()) print(runInfo())
elif func == 'conf': elif func == 'conf':
print(getConf()) print(getConf())
elif func == 'conf_service':
print(confService())
elif func == 'run_log': elif func == 'run_log':
print(runLog()) print(runLog())
elif func == 'config_tpl': elif func == 'config_tpl':

@ -9,7 +9,7 @@ function pRead(){
} }
//redis负载状态 start //varnish负载状态 start
function varnishStatus() { function varnishStatus() {
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'varnish', func:'run_info'}, function(data) { $.post('/plugins/run', {name:'varnish', func:'run_info'}, function(data) {
@ -41,4 +41,61 @@ function varnishStatus() {
$(".soft-man-con").html(Con); $(".soft-man-con").html(Con);
},'json'); },'json');
} }
//redis负载状态 end //varnish负载状态 end
//varnish service ---
function varnishPluginConfig(_name, version, func){
if ( typeof(version) == 'undefined' ){
version = '';
}
var func_name = 'conf';
if ( typeof(func) != 'undefined' ){
func_name = func;
}
var con = '<p style="color: #666; margin-bottom: 7px">提示Ctrl+F 搜索关键字Ctrl+G 查找下一个Ctrl+S 保存Ctrl+Shift+R 查找替换!</p>\
<textarea class="bt-input-text" style="height: 320px; line-height:18px;" id="textBody"></textarea>\
<button id="onlineEditFileBtn" class="btn btn-success btn-sm" style="margin-top:10px;">保存</button>\
<ul class="help-info-text c7 ptb15">\
<li>此处为'+ _name + version +'主配置文件,若您不了解配置规则,请勿随意修改</li>\
</ul>';
$(".soft-man-con").html(con);
var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/plugins/run', {name:_name, func:func_name,version:version},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() {
$("#textBody").text(editor.getValue());
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');
}

@ -22,6 +22,6 @@ zmq==0.0.0
pymongo pymongo
pillow pillow
Jinja2>=2.11.2 Jinja2>=2.11.2
mysqlclient>=2.0.3
flask-caching>=1.10.1 flask-caching>=1.10.1
mysql-connector-python mysql-connector-python
mysqlclient>=2.0.3

@ -33,7 +33,7 @@ function getSList(isdisplay) {
var loadT = layer.msg('正在获取列表...', { icon: 16, time: 0, shade: [0.3, '#000'] }) var loadT = layer.msg('正在获取列表...', { icon: 16, time: 0, shade: [0.3, '#000'] })
} }
if (!isdisplay || isdisplay === true) if (!isdisplay || isdisplay === true)
isdisplay = getCookie('p' + getCookie('softType')); isdisplay = getCookie('p' + getCookie('soft_type'));
if (isdisplay == true || isdisplay == 'true') isdisplay = 1; if (isdisplay == true || isdisplay == 'true') isdisplay = 1;
var search = $("#SearchValue").val(); var search = $("#SearchValue").val();
@ -41,7 +41,7 @@ function getSList(isdisplay) {
search = '&search=' + search; search = '&search=' + search;
} }
var type = ''; var type = '';
var istype = getCookie('softType'); var istype = getCookie('soft_type');
if (istype == 'undefined' || istype == 'null' || !istype) { if (istype == 'undefined' || istype == 'null' || !istype) {
istype = '0'; istype = '0';
} }
@ -50,7 +50,7 @@ function getSList(isdisplay) {
var page = ''; var page = '';
if (isdisplay) { if (isdisplay) {
page = '&p=' + isdisplay; page = '&p=' + isdisplay;
setCookie('p' + getCookie('softType'), isdisplay); setCookie('p' + getCookie('soft_type'), isdisplay);
} }
var condition = (search + type + page).slice(1); var condition = (search + type + page).slice(1);
@ -162,7 +162,7 @@ function getSList(isdisplay) {
sBody += pBody; sBody += pBody;
$("#softList").html(sBody); $("#softList").html(sBody);
$(".menu-sub span").click(function() { $(".menu-sub span").click(function() {
setCookie('softType', $(this).attr('typeid')); setCookie('soft_type', $(this).attr('typeid'));
$(this).addClass("on").siblings().removeClass("on"); $(this).addClass("on").siblings().removeClass("on");
getSList(); getSList();
}); });

@ -3,12 +3,21 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH export PATH
LANG=en_US.UTF-8 LANG=en_US.UTF-8
# RED='\e[1;31m' # 红色
# GREEN='\e[1;32m' # 绿色
# YELLOW='\e[1;33m' # 黄色
# BLUE='\e[1;34m' # 蓝色
# PURPLE='\e[1;35m' # 紫色
# CYAN='\e[1;36m' # 蓝绿色
# WHITE='\e[1;37m' # 白色
# NC='\e[0m' # 没有颜色
apt update -y apt update -y
apt install -y wget curl lsof unzip apt install -y wget curl lsof unzip
apt install -y python3-pip apt install -y python3-pip
apt install -y python3-dev
apt install -y python3-venv apt install -y python3-venv
apt install -y cron apt install -y cron
@ -60,16 +69,47 @@ fi
systemctl stop firewalld systemctl stop firewalld
#fix zlib1g-dev fail
echo -e "\e[0;32mfix zlib1g-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-zlib1g-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
ZLIB1G_BASE_VER=$(cat ${Install_TmpFile} | grep zlib1g | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
ZLIB1G_BASE_VER=`echo ${ZLIB1G_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
# echo "1${ZLIB1G_BASE_VER}1"
echo -e "\e[1;31mapt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev\e[0m"
echo "Y" | apt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix zlib1g-dev install question end\e[0m"
#fix libunwind-dev fail
echo -e "\e[0;32mfix libunwind-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-libunwind-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
liblzma5_BASE_VER=$(cat ${Install_TmpFile} | grep liblzma-dev | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
liblzma5_BASE_VER=`echo ${liblzma5_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
echo -e "\e[1;31mapt install liblzma5=${liblzma5_BASE_VER} libunwind-dev\e[0m"
echo "Y" | apt install liblzma5=${liblzma5_BASE_VER} libunwind-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix libunwind-dev install question end\e[0m"
cd /www/server/mdserver-web/scripts && bash lib.sh cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data chmod 755 /www/server/mdserver-web/data
if [ ! -f /usr/local/bin/pip3 ];then if [ ! -f /usr/local/bin/pip3 ];then
python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple
fi fi
pip install --upgrade pip pip install --upgrade pip
pip install --upgrade setuptools
sed -i "/mysqlclient/d" /www/server/mdserver-web/requirements.txt
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt
pip3 install gunicorn==20.1.0 pip3 install gunicorn==20.1.0
@ -77,24 +117,23 @@ pip3 install gevent==21.1.2
pip3 install gevent-websocket==0.10.1 pip3 install gevent-websocket==0.10.1
pip3 install requests==2.20.0 pip3 install requests==2.20.0
pip3 install flask-caching==1.10.1 pip3 install flask-caching==1.10.1
pip3 install flask-socketio==5.2.0
pip3 install pymongo pip3 install pymongo
pip3 install psutil pip3 install psutil
pip3 install flask-socketio==5.2.0
if [ ! -f /www/server/mdserver-web/bin/activate ];then if [ ! -f /www/server/mdserver-web/bin/activate ];then
cd /www/server/mdserver-web && python3 -m venv . cd /www/server/mdserver-web && python3 -m venv .
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
pip install --upgrade pip pip install --upgrade pip
pip3 install -r /www/server/mdserver-web/requirements.txt pip3 install -r /www/server/mdserver-web/requirements.txt
pip install --upgrade setuptools
pip3 install gunicorn==20.1.0 pip3 install gunicorn==20.1.0
pip3 install gevent==21.1.2 pip3 install gevent==21.1.2
pip3 install gevent-websocket==0.10.1 pip3 install gevent-websocket==0.10.1
pip3 install requests==2.20.0 pip3 install requests==2.20.0
pip3 install flask-caching==1.10.1 pip3 install flask-caching==1.10.1
pip3 install flask-socketio==5.2.0
pip3 install pymongo pip3 install pymongo
pip3 install psutil pip3 install psutil
pip3 install flask-socketio==5.2.0
fi fi

@ -9,6 +9,8 @@ apt update -y
apt install -y wget curl lsof unzip apt install -y wget curl lsof unzip
apt install -y python3-pip apt install -y python3-pip
apt install -y python3-venv apt install -y python3-venv
apt install -y python3-dev
apt install -y cron apt install -y cron

@ -44,6 +44,7 @@ elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; th
yum install -y wget zip unzip yum install -y wget zip unzip
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian' OSNAME='debian'
apt install -y devscripts
apt install -y wget zip unzip apt install -y wget zip unzip
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu' OSNAME='ubuntu'

@ -295,16 +295,19 @@ elif [ "$OSNAME" == "ubuntu" ] || [ "$OSNAME" == "debian" ]; then
apt install -y cmake automake make apt install -y cmake automake make
apt install -y webp scons apt install -y webp scons
apt install -y lzma lzma-dev libunwind-dev apt install -y lzma lzma-dev
apt install -y libunwind-dev
apt install -y libpcre3 libpcre3-dev apt install -y libpcre3 libpcre3-dev
apt install -y openssl apt install -y openssl
apt install -y libxml2 libxml2-dev libbz2-dev libmcrypt-dev libpspell-dev librecode-dev apt install -y libxml2 libxml2-dev libbz2-dev libmcrypt-dev libpspell-dev librecode-dev
apt install -y libgmp-dev libgmp3-dev libreadline-dev libxpm-dev apt install -y libgmp-dev libgmp3-dev libreadline-dev libxpm-dev
apt install -y zlib1g-dev dia pkg-config apt install -y dia pkg-config
apt install -y libjpeg62-turbo-dev libjpeg-dev libpng-dev apt install -y zlib1g-dev
apt install -y libjpeg-dev libpng-dev
apt install -y libfreetype6 apt install -y libfreetype6
apt install -y libjpeg62-turbo-dev
apt install -y libfreetype6-dev apt install -y libfreetype6-dev
apt install -y libevent-dev libncurses5-dev libldap2-dev apt install -y libevent-dev libncurses5-dev libldap2-dev

@ -21,6 +21,7 @@ fi
pip install --upgrade pip pip install --upgrade pip
pip install --upgrade setuptools pip install --upgrade setuptools
sed -i "/mysqlclient/d" /www/server/mdserver-web/requirements.txt
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt
pip3 install gunicorn==20.1.0 pip3 install gunicorn==20.1.0

@ -75,7 +75,6 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True):
import shlex import shlex
import datetime import datetime
import subprocess import subprocess
import time
if timeout: if timeout:
end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout) end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout)
@ -226,7 +225,6 @@ def systemTask():
try: try:
import system_api import system_api
import psutil import psutil
import time
sm = system_api.system_api() sm = system_api.system_api()
filename = 'data/control.conf' filename = 'data/control.conf'
@ -368,7 +366,7 @@ def systemTask():
mw.writeFile('logs/sys_interrupt.pl', str(ex)) mw.writeFile('logs/sys_interrupt.pl', str(ex))
restartMw() restartMw()
import time
time.sleep(30) time.sleep(30)
systemTask() systemTask()
@ -388,17 +386,18 @@ def check502Task():
def check502(): def check502():
try: try:
phpversions = ['53', '54', '55', '56', '70', '71', '72', '73', '74'] verlist = ['52', '53', '54', '55', '56', '70',
for version in phpversions: '71', '72', '73', '74', '80', '81']
for ver in verlist:
sdir = mw.getServerDir() sdir = mw.getServerDir()
php_path = sdir + '/php/' + version + '/sbin/php-fpm' php_path = sdir + '/php/' + ver + '/sbin/php-fpm'
if not os.path.exists(php_path): if not os.path.exists(php_path):
continue continue
if checkPHPVersion(version): if checkPHPVersion(ver):
continue continue
if startPHPVersion(version): if startPHPVersion(ver):
print('检测到PHP-' + version + '处理异常,已自动修复!') print('检测到PHP-' + ver + '处理异常,已自动修复!')
mw.writeLog('PHP守护程序', '检测到PHP-' + version + '处理异常,已自动修复!') mw.writeLog('PHP守护程序', '检测到PHP-' + ver + '处理异常,已自动修复!')
except Exception as e: except Exception as e:
print(str(e)) print(str(e))
@ -452,8 +451,8 @@ def checkPHPVersion(version):
try: try:
url = 'http://127.0.0.1/phpfpm_status_' + version url = 'http://127.0.0.1/phpfpm_status_' + version
result = mw.httpGet(url) result = mw.httpGet(url)
# print version,result # print(version,result)
# 检查nginx # 检查openresty
if result.find('Bad Gateway') != -1: if result.find('Bad Gateway') != -1:
return False return False
if result.find('HTTP Error 404: Not Found') != -1: if result.find('HTTP Error 404: Not Found') != -1:
@ -466,17 +465,52 @@ def checkPHPVersion(version):
isStatus = mw.readFile(isTask) isStatus = mw.readFile(isTask)
if isStatus == 'True': if isStatus == 'True':
return True return True
filename = '/etc/init.d/openresty'
if os.path.exists(filename): # systemd
os.system(filename + ' start') systemd = '/lib/systemd/system/openresty.service'
if os.path.exists(systemd):
execShell('systemctl reload openresty')
return True
# initd
initd = '/etc/init.d/openresty'
if os.path.exists(initd):
os.system(initd + ' reload')
return True return True
except: except:
return True return True
# --------------------------------------PHP监控 end--------------------------------------------- # # --------------------------------------PHP监控 end--------------------------------------------- #
# --------------------------------------OpenResty Auto Restart Start --------------------------------------------- #
# 解决acme.sh续签后,未起效。
def openrestyAutoRestart():
try:
while True:
# 检查是否安装
odir = mw.getServerDir() + '/openresty'
if not os.path.exists(odir):
time.sleep(86400)
continue
# systemd
systemd = '/lib/systemd/system/openresty.service'
initd = '/etc/init.d/openresty'
if os.path.exists(systemd):
execShell('systemctl reload openresty')
elif os.path.exists(initd):
os.system(initd + ' reload')
time.sleep(86400)
except Exception as e:
print(str(e))
time.sleep(86400)
# --------------------------------------OpenResty Auto Restart End --------------------------------------------- #
if __name__ == "__main__": if __name__ == "__main__":
# 系统监控
t = threading.Thread(target=systemTask) t = threading.Thread(target=systemTask)
if sys.version_info.major == 3 and sys.version_info.minor >= 10: if sys.version_info.major == 3 and sys.version_info.minor >= 10:
t.daemon = True t.daemon = True
@ -484,12 +518,20 @@ if __name__ == "__main__":
t.setDaemon(True) t.setDaemon(True)
t.start() t.start()
# PHP 502错误检查线程
p = threading.Thread(target=check502Task) p = threading.Thread(target=check502Task)
if sys.version_info.major == 3 and sys.version_info.minor >= 10: if sys.version_info.major == 3 and sys.version_info.minor >= 10:
p.daemon = True p.daemon = True
else: else:
p.setDaemon(True) p.setDaemon(True)
p.start() p.start()
# OpenResty Auto Restart Start
oar = threading.Thread(target=openrestyAutoRestart)
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
oar.daemon = True
else:
oar.setDaemon(True)
oar.start()
startTask() startTask()

Loading…
Cancel
Save