diff --git a/class/core/common.py b/class/core/common.py new file mode 100755 index 000000000..26131327b --- /dev/null +++ b/class/core/common.py @@ -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 diff --git a/class/core/system_api.py b/class/core/system_api.py index cf245d160..6267787df 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -69,6 +69,14 @@ class system_api: end = request.args.get('end', '') data = self.getNetWorkIoData(start, end) return public.getJson(data) + + # 重启面板 + def restartApi(self): + + cmd = public.getRunDir() + '/scripts/init.d/mw restart &' + print public.execShell(cmd) + + return public.returnJson(True, '面板已重启!') ##### ----- end ----- ### # 名取PID diff --git a/route/static/app/index.js b/route/static/app/index.js index aa3d56650..9d9296ad1 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -606,34 +606,119 @@ function updateInstall(){ } //重启服务器 -function ReBoot() { +function reBoot() { layer.open({ type: 1, - title: lan.index.reboot_title, - area: ['500px', '280px'], + title: '重启服务器或者面板', + area: '330px', closeBtn: 2, shadeClose: false, - content: "
\ -
\ -

" + lan.index.reboot_warning + "

\ -
\ -

" + lan.index.reboot_ps + "

\ -

" + lan.index.reboot_ps_1 + "

\ -

" + lan.index.reboot_ps_2 + "

\ -

" + lan.index.reboot_ps_3 + "

\ -

" + lan.index.reboot_ps_4 + "

\ -
\ -
\ -
\ - \ - \ -
\ -
" - }) + content: '
重启服务器
重启面板
' + }); + + + $('.rebt-con a').click(function () { + var type = $(this).attr('data-id'); + switch (type) { + case 'panel': + layer.confirm('即将重启面板服务,继续吗?', { title: lan.index.panel_reboot_title, closeBtn: 2, icon: 3 }, function () { + var loadT = layer.load(); + $.post('/system/restart','',function (rdata) { + layer.close(loadT); + layer.msg(rdata.msg); + setTimeout(function () { window.location.reload(); }, 3000); + },'json'); + }); + break; + case 'server': + var rebootbox = bt.open({ + type: 1, + title: lan.index.reboot_title, + area: ['500px', '280px'], + closeBtn: 2, + shadeClose: false, + content: "
\ +
\ +

"+ lan.index.reboot_warning + "

\ +
\ +

"+ lan.index.reboot_ps + "

\ +

"+ lan.index.reboot_ps_1 + "

\ +

"+ lan.index.reboot_ps_2 + "

\ +

"+ lan.index.reboot_ps_3 + "

\ +

"+ lan.index.reboot_ps_4 + "

\ +
\ +
\ +
\ + \ + \ +
\ +
" + }); + setTimeout(function () { + $(".btn-reboot").click(function () { + rebootbox.close(); + }) + $(".WSafeRestart").click(function () { + var body = '
'; + $(".bt-window-restart").html(body); + $(".SafeRestartCode").append("

" + lan.index.reboot_msg_1 + "

"); + bt.pub.set_server_status_by("name={{session['webserver']}}&type=stop", function (r1) { + $(".SafeRestartCode p").addClass('c9'); + $(".SafeRestartCode").append("

" + lan.index.reboot_msg_2 + "...

"); + bt.pub.set_server_status_by("name=mysqld&type=stop", function (r2) { + $(".SafeRestartCode p").addClass('c9'); + $(".SafeRestartCode").append("

" + lan.index.reboot_msg_3 + "...

"); + bt.system.root_reload(function (rdata) { + $(".SafeRestartCode p").addClass('c9'); + $(".SafeRestartCode").append("

" + lan.index.reboot_msg_4 + "...

"); + var sEver = setInterval(function () { + bt.system.get_total(function () { + clearInterval(sEver); + $(".SafeRestartCode p").addClass('c9'); + $(".SafeRestartCode").append("

" + lan.index.reboot_msg_5 + "...

"); + 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: "
\ + //
\ + //

" + lan.index.reboot_warning + "

\ + //
\ + //

" + lan.index.reboot_ps + "

\ + //

" + lan.index.reboot_ps_1 + "

\ + //

" + lan.index.reboot_ps_2 + "

\ + //

" + lan.index.reboot_ps_3 + "

\ + //

" + lan.index.reboot_ps_4 + "

\ + //
\ + //
\ + //
\ + // \ + // \ + //
\ + //
" + // }) } //重启服务器 -function WSafeRestart() { +function wSafeRestart() { var body = '
'; $(".bt-window-restart").html(body); var data = "name=" + serverType + "&type=stop"; @@ -705,7 +790,7 @@ function repPanel() { } //获取警告信息 -function GetWarning() { +function getWarning() { $.get('/ajax?action=GetWarning', function(wlist) { var num = 0; 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'] }); $.post(to_url, {}, function(rdata) { layer.close(loadT); @@ -736,7 +821,7 @@ function WarningTo(to_url, def) { }); } -function SetSafeHide() { +function setSafeHide() { setCookie('safeMsg', '1'); $("#safeMsg").remove(); } diff --git a/route/templates/default/index.html b/route/templates/default/index.html index e8f8c5b7b..5c205fbbe 100755 --- a/route/templates/default/index.html +++ b/route/templates/default/index.html @@ -9,7 +9,7 @@ {{config.version}} 更新 修复 - 重启 + 重启 diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index e5ee95adf..8c594a9a6 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -129,7 +129,6 @@ case "$1" in 'reload') mw_reload;; 'restart') mw_stop - sleep 0.3 mw_start;; 'status') mw_status;; 'logs') error_logs;;