pull/109/head
Mr Chen 6 years ago
parent 4a751411c7
commit ed466560d9
  1. 17
      class/core/common.py
  2. 8
      class/core/system_api.py
  3. 133
      route/static/app/index.js
  4. 2
      route/templates/default/index.html
  5. 1
      scripts/init.d/mw.tpl

@ -0,0 +1,17 @@
# coding: utf-8
import os
import sys
import time
import string
import json
import hashlib
import shlex
import datetime
import subprocess
import re
import hashlib
import db
from random import Random

@ -69,6 +69,14 @@ class system_api:
end = request.args.get('end', '') end = request.args.get('end', '')
data = self.getNetWorkIoData(start, end) data = self.getNetWorkIoData(start, end)
return public.getJson(data) return public.getJson(data)
# 重启面板
def restartApi(self):
cmd = public.getRunDir() + '/scripts/init.d/mw restart &'
print public.execShell(cmd)
return public.returnJson(True, '面板已重启!')
##### ----- end ----- ### ##### ----- end ----- ###
# 名取PID # 名取PID

@ -606,34 +606,119 @@ function updateInstall(){
} }
//重启服务器 //重启服务器
function ReBoot() { function reBoot() {
layer.open({ layer.open({
type: 1, type: 1,
title: lan.index.reboot_title, title: '重启服务器或者面板',
area: ['500px', '280px'], area: '330px',
closeBtn: 2, closeBtn: 2,
shadeClose: false, shadeClose: false,
content: "<div class='bt-form bt-window-restart'>\ content: '<div class="rebt-con"><div class="rebt-li"><a data-id="server" href="javascript:;">重启服务器</a></div><div class="rebt-li"><a data-id="panel" href="javascript:;">重启面板</a></div></div>'
<div class='pd15'>\ });
<p style='color:red; margin-bottom:10px; font-size:15px;'>" + lan.index.reboot_warning + "</p>\
<div class='SafeRestart' style='line-height:26px'>\
<p>" + lan.index.reboot_ps + "</p>\ $('.rebt-con a').click(function () {
<p>" + lan.index.reboot_ps_1 + "</p>\ var type = $(this).attr('data-id');
<p>" + lan.index.reboot_ps_2 + "</p>\ switch (type) {
<p>" + lan.index.reboot_ps_3 + "</p>\ case 'panel':
<p>" + lan.index.reboot_ps_4 + "</p>\ layer.confirm('即将重启面板服务,继续吗?', { title: lan.index.panel_reboot_title, closeBtn: 2, icon: 3 }, function () {
</div>\ var loadT = layer.load();
</div>\ $.post('/system/restart','',function (rdata) {
<div class='bt-form-submit-btn'>\ layer.close(loadT);
<button type='button' id='web_end_time' class='btn btn-danger btn-sm btn-title' onclick='layer.closeAll()'>" + lan.public.cancel + "</button>\ layer.msg(rdata.msg);
<button type='button' id='web_del_send' class='btn btn-success btn-sm btn-title' onclick='WSafeRestart()'>" + lan.public.ok + "</button>\ setTimeout(function () { window.location.reload(); }, 3000);
</div>\ },'json');
</div>" });
}) break;
case 'server':
var rebootbox = bt.open({
type: 1,
title: lan.index.reboot_title,
area: ['500px', '280px'],
closeBtn: 2,
shadeClose: false,
content: "<div class='bt-form bt-window-restart'>\
<div class='pd15'>\
<p style='color:red; margin-bottom:10px; font-size:15px;'>"+ lan.index.reboot_warning + "</p>\
<div class='SafeRestart' style='line-height:26px'>\
<p>"+ lan.index.reboot_ps + "</p>\
<p>"+ lan.index.reboot_ps_1 + "</p>\
<p>"+ lan.index.reboot_ps_2 + "</p>\
<p>"+ lan.index.reboot_ps_3 + "</p>\
<p>"+ lan.index.reboot_ps_4 + "</p>\
</div>\
</div>\
<div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-danger btn-sm btn-reboot'>"+ lan.public.cancel + "</button>\
<button type='button' class='btn btn-success btn-sm WSafeRestart' >"+ lan.public.ok + "</button>\
</div>\
</div>"
});
setTimeout(function () {
$(".btn-reboot").click(function () {
rebootbox.close();
})
$(".WSafeRestart").click(function () {
var body = '<div class="SafeRestartCode pd15" style="line-height:26px"></div>';
$(".bt-window-restart").html(body);
$(".SafeRestartCode").append("<p>" + lan.index.reboot_msg_1 + "</p>");
bt.pub.set_server_status_by("name={{session['webserver']}}&type=stop", function (r1) {
$(".SafeRestartCode p").addClass('c9');
$(".SafeRestartCode").append("<p>" + lan.index.reboot_msg_2 + "...</p>");
bt.pub.set_server_status_by("name=mysqld&type=stop", function (r2) {
$(".SafeRestartCode p").addClass('c9');
$(".SafeRestartCode").append("<p>" + lan.index.reboot_msg_3 + "...</p>");
bt.system.root_reload(function (rdata) {
$(".SafeRestartCode p").addClass('c9');
$(".SafeRestartCode").append("<p>" + lan.index.reboot_msg_4 + "...</p>");
var sEver = setInterval(function () {
bt.system.get_total(function () {
clearInterval(sEver);
$(".SafeRestartCode p").addClass('c9');
$(".SafeRestartCode").append("<p>" + lan.index.reboot_msg_5 + "...</p>");
setTimeout(function () {
layer.closeAll();
}, 3000);
})
}, 3000);
})
})
})
})
}, 100);
break;
}
});
// layer.open({
// type: 1,
// title: lan.index.reboot_title,
// area: ['500px', '280px'],
// closeBtn: 2,
// shadeClose: false,
// content: "<div class='bt-form bt-window-restart'>\
// <div class='pd15'>\
// <p style='color:red; margin-bottom:10px; font-size:15px;'>" + lan.index.reboot_warning + "</p>\
// <div class='SafeRestart' style='line-height:26px'>\
// <p>" + lan.index.reboot_ps + "</p>\
// <p>" + lan.index.reboot_ps_1 + "</p>\
// <p>" + lan.index.reboot_ps_2 + "</p>\
// <p>" + lan.index.reboot_ps_3 + "</p>\
// <p>" + lan.index.reboot_ps_4 + "</p>\
// </div>\
// </div>\
// <div class='bt-form-submit-btn'>\
// <button type='button' id='web_end_time' class='btn btn-danger btn-sm btn-title' onclick='layer.closeAll()'>" + lan.public.cancel + "</button>\
// <button type='button' id='web_del_send' class='btn btn-success btn-sm btn-title' onclick='WSafeRestart()'>" + lan.public.ok + "</button>\
// </div>\
// </div>"
// })
} }
//重启服务器 //重启服务器
function WSafeRestart() { function wSafeRestart() {
var body = '<div class="SafeRestartCode pd15" style="line-height:26px"></div>'; var body = '<div class="SafeRestartCode pd15" style="line-height:26px"></div>';
$(".bt-window-restart").html(body); $(".bt-window-restart").html(body);
var data = "name=" + serverType + "&type=stop"; var data = "name=" + serverType + "&type=stop";
@ -705,7 +790,7 @@ function repPanel() {
} }
//获取警告信息 //获取警告信息
function GetWarning() { function getWarning() {
$.get('/ajax?action=GetWarning', function(wlist) { $.get('/ajax?action=GetWarning', function(wlist) {
var num = 0; var num = 0;
for (var i = 0; i < wlist.data.length; i++) { for (var i = 0; i < wlist.data.length; i++) {
@ -727,7 +812,7 @@ function GetWarning() {
} }
//按钮调用 //按钮调用
function WarningTo(to_url, def) { function warningTo(to_url, def) {
var loadT = layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] }); var loadT = layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post(to_url, {}, function(rdata) { $.post(to_url, {}, function(rdata) {
layer.close(loadT); layer.close(loadT);
@ -736,7 +821,7 @@ function WarningTo(to_url, def) {
}); });
} }
function SetSafeHide() { function setSafeHide() {
setCookie('safeMsg', '1'); setCookie('safeMsg', '1');
$("#safeMsg").remove(); $("#safeMsg").remove();
} }

@ -9,7 +9,7 @@
<span id="btversion" onclick="index.open_log()" style="margin-right:10px">{{config.version}}</span> <span id="btversion" onclick="index.open_log()" style="margin-right:10px">{{config.version}}</span>
<span id="toUpdate"><a class="btlink" href="javascript:checkUpdate();">更新</a></span> <span id="toUpdate"><a class="btlink" href="javascript:checkUpdate();">更新</a></span>
<span style="margin:0 10px"><a class="btlink" href="javascript:index.re_panel();">修复</a></span> <span style="margin:0 10px"><a class="btlink" href="javascript:index.re_panel();">修复</a></span>
<span><a class="btlink" href="javascript:index.re_server();">重启</a></span> <span><a class="btlink" href="javascript:reBoot();">重启</a></span>
</span> </span>
</div> </div>

@ -129,7 +129,6 @@ case "$1" in
'reload') mw_reload;; 'reload') mw_reload;;
'restart') 'restart')
mw_stop mw_stop
sleep 0.3
mw_start;; mw_start;;
'status') mw_status;; 'status') mw_status;;
'logs') error_logs;; 'logs') error_logs;;

Loading…
Cancel
Save