GoodTimes font / simple server status
This commit is contained in:
FangfangZhao 2018-10-31 22:09:23 +08:00
parent 41011d05e8
commit 6756056eb3
12 changed files with 93 additions and 30 deletions

View file

@ -18,6 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
package com.rebuild.server;
import java.util.Date;
import javax.servlet.ServletContextEvent;
import org.apache.commons.logging.Log;
@ -26,6 +28,8 @@ import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import cn.devezhao.commons.CalendarUtils;
/**
* 服务启动/停止监听
*
@ -37,6 +41,8 @@ public class ServerListener extends ContextLoaderListener {
private static final Log LOG = LogFactory.getLog(ServerListener.class);
private static String CONTEXT_PATH = "";
private static Date STARTUP_TIME = CalendarUtils.now();
@Override
public void contextInitialized(ServletContextEvent event) {
@ -51,6 +57,7 @@ public class ServerListener extends ContextLoaderListener {
super.contextInitialized(event);
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
new Application(wac).init(at);
STARTUP_TIME = CalendarUtils.now();
} catch (Throwable ex) {
LOG.fatal("Rebuild Booting failure!!!", ex);
System.exit(-1);
@ -63,12 +70,19 @@ public class ServerListener extends ContextLoaderListener {
super.contextDestroyed(event);
}
// --
/**
* 获取部署路径
*
* @return
*/
public static String getContextPath() {
return CONTEXT_PATH;
}
/**
* @return
*/
public static Date getStartupTime() {
return STARTUP_TIME;
}
}

View file

@ -42,6 +42,8 @@ public class ServersStatus {
private static final Map<String, String> LAST_STATUS = new ConcurrentHashMap<>();
static {
LAST_STATUS.put("DataSource", EMPTY);
LAST_STATUS.put("StroageService", EMPTY);
LAST_STATUS.put("CacheService", EMPTY);
}
/**
* 最近检查状态

View file

@ -51,7 +51,6 @@ public class RequestWatchHandler extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if (!ServersStatus.isStatusOK()) {
ServletUtils.forward(request, response, "/servers-status.jsp");
return false;

View file

@ -3,6 +3,7 @@
<%@ page import="com.rebuild.utils.AppUtils"%>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="${baseUrl}/assets/img/favicon.png" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/lib/material-design-iconic-font.min.css">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/lib/widget/perfect-scrollbar.min.css">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/lib/widget/bootstrap-datetimepicker.min.css">

View file

@ -266,7 +266,8 @@ figure {
img {
vertical-align: middle;
border-style: none
border-style: none;
max-height: 24px;
}
svg:not(:root) {
@ -10659,10 +10660,11 @@ canvas {
.rb-top-header .rb-navbar-header .navbar-brand {
line-height: 60px;
height: 60px;
width: 142px;
width: 146px;
background-image: url(../img/logo.png);
background-repeat: no-repeat;
background-position: 20px center;
background-size: auto 20px;
padding: 0 20px;
margin: 0;
display: block
@ -10688,10 +10690,6 @@ canvas {
}
}
.rb-nosidebar-left .rb-top-header .rb-navbar-header .navbar-brand {
width: 142px
}
.rb-collapsible-sidebar-hide-logo.rb-collapsible-sidebar-collapsed .rb-top-header .rb-navbar-header .navbar-brand {
display: none
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

@ -17,9 +17,7 @@ errorCode = errorCode == null ? 400 : errorCode;
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/lib/material-design-iconic-font.min.css">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/css/rb-base.css">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/css/rb-page.css">
<title>提示</title>
</head>
<body class="rb-splash-screen">
@ -31,7 +29,8 @@ errorCode = errorCode == null ? 400 : errorCode;
<div class="error-description"><%=errorMsg%></div>
<div class="error-goback-button">
<a class="btn btn-xl btn-primary hide J_home" href="${baseUrl}/dashboard/home">返回首页</a>
<a class="btn btn-xl btn-primary hide J_reload" href="javascript:;" onclick="location.reload(true)">刷新</a>
&nbsp;
<a class="btn btn-xl btn-primary hide J_reload" href="javascript:;" onclick="location.reload(true)">重试</a>
</div>
</div>
</div>
@ -42,6 +41,7 @@ errorCode = errorCode == null ? 400 : errorCode;
(function(){
if (self != top) $('.J_reload').removeClass('hide')
else $('.J_home').removeClass('hide')
if ($('.error-number').text() == '404') $('.J_reload').remove()
})()
</script>
</body>

View file

@ -1,34 +1,83 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.rebuild.server.helper.SystemConfigurer"%>
<%@ page import="org.apache.commons.lang.SystemUtils"%>
<%@ page import="cn.devezhao.commons.CalendarUtils"%>
<%@ page import="java.util.Calendar"%>
<%@ page import="com.rebuild.server.ServerListener"%>
<%@ page import="com.rebuild.server.Application"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%@ page import="com.rebuild.server.ServersStatus"%>
<%@ page import="java.util.Map"%>
<%@ page import="com.rebuild.web.common.SimplePageForward"%>
<%
SimplePageForward.setPageAttribute(request);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="${baseUrl}/assets/css/rb-base.css">
<title>服务不可用</title>
<link rel="stylesheet" type="text/css" href="<%=ServerListener.getContextPath()%>/assets/css/rb-base.css">
<title>服务状态</title>
<style type="text/css">
h4{padding:16px 32px;padding-bottom:6px}
.error-description{background-color:#fff;border:1px solid #ccc;padding:16px}
.error-description dl{margin:0}
.block{margin:0 auto;max-width:1000px;margin-bottom:32px;padding:0 14px}
</style>
</head>
<body>
<div>
<h4>以下服务不可用</h4>
<div class="error-description">
<div class="block">
<h5 class="text-bold">快速检查</h5>
<table class="table table-bordered table-sm">
<tbody>
<% for (Map.Entry<String, String> e : ServersStatus.getLastStatus().entrySet()) { %>
<dl class="row">
<dt class="col-2"><%=e.getKey()%></dt>
<dd class="col-10"><%=e.getValue()%></dd>
</dl>
<tr>
<th><%=e.getKey()%></th>
<td><%=e.getValue() == StringUtils.EMPTY ? "OK" : e.getValue()%></td>
</tr>
<% }%>
</div>
<tr>
<th width="30%">Memory Usage</th>
<td>n/a</td>
</tr>
<tr>
<th>CPU Usage</th>
<td>n/a</td>
</tr>
</tbody>
</table>
</div>
<div class="block">
<h5 class="text-bold">系统信息</h5>
<table class="table table-bordered table-sm">
<tbody>
<tr>
<th width="30%">版本</th>
<td><a href="https://github.com/getrebuild/rebuild/releases"><%=Application.VER%></a></td>
</tr>
<tr>
<th>启动时间</th>
<td><%=ServerListener.getStartupTime()%></td>
</tr>
<tr>
<th>系统时间</th>
<td><%=CalendarUtils.now()%></td>
</tr>
<tr>
<th>OS</th>
<td><%=SystemUtils.OS_NAME%> (<%=SystemUtils.OS_ARCH%>)</td>
</tr>
<tr>
<th>JVM</th>
<td><%=SystemUtils.JAVA_VERSION%> (<%=SystemUtils.JAVA_VENDOR%>)</td>
</tr>
<tr>
<th>Catalina Base</th>
<td><%=System.getProperty("catalina.base")%></td>
</tr>
<tr>
<th>Temp Directory</th>
<td><%=SystemConfigurer.getFileOfTemp("/")%></td>
</tr>
</tbody>
</table>
</div>
<div class="block">
<div class="text-muted">&copy; 2018 <a href="https://github.com/getrebuild/rebuild/">Rebuild</a></div>
</div>
</body>
</html>

View file

@ -14,7 +14,7 @@
<div class="splash-container">
<div class="card card-border-color card-border-color-primary">
<div class="card-header">
<img class="logo-img" src="../assets/img/logo.png" alt="REBUILD" width="102" height="27">
<img class="logo-img" src="../assets/img/logo.png" alt="REBUILD">
</div>
<div class="card-body">
<div class="form-group">