Page control of whether the back-end web application is available when apache is used as an access

Apache is used as the front-end access, and the back-end is transferred to the tomcat-based web application. Sometimes, due to system upgrades or other reasons, when the back-end web application cannot be used for a certain period of time, in order to friendly notify the user that the system is temporarily unavailable. Use, use javascript in the index.html page to judge whether it is currently available, and go to service_stop.html according to the judgment result, or the index.html page of the web app.

 

<HTML>

<HEAD>

<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">

	var stopFlag = false;
		
	var sysDateTime = new Date ();
	
	var sysYear = sysDateTime.getFullYear ();
	
	var sysMonth = sysDateTime.getMonth() + 1;
	if(sysMonth < 10){
		sysMonth = '0' + sysMonth;
	}

	var sysDate = sysDateTime.getDate();
	if(sysDate < 10){
		sysDate = '0' + sysDate;
	}
	
	var sysHour = sysDateTime.getHours();
	if(sysHour < 10){
		sysHour = '0' + sysHour;
	}
	
	var sysMinute = sysDateTime.getMinutes();
	if(sysMinute < 10){
		sysMinute = '0' + sysMinute;
	}
	
	var sysSecond = sysDateTime.getSeconds ();
	if(sysSecond < 10){
		sysSecond = '0' + sysSecond;
	}
	
	var sysYmd = sysYear + '/' + sysMonth + '/' + sysDate;
	var sysHms = sysHour + ':' + sysMinute + ':' + sysSecond;
	
	if(sysYmd == '2017/01/15' && sysHms > '08:00:00'){
		stopFlag = true;
	} else if (sysYmd == '2017/01/03'){
		stopFlag = true;
	} else if(sysYmd == '2016/11/11'){
		stopFlag = true;
	} else if(sysYmd == '2017/02/12' && sysHms > '08:00:00' && sysHms < '18:30:00'){
		stopFlag = true;
	} else if( (sysYmd == '2016/10/16' && sysHms > '22:00:00') || (sysYmd == '2016/10/27' && sysHms < '20:00:00') ){
		stopFlag = true;
	} else if(sysYmd >= '2016/10/10' && sysYmd <= '2016/10/11'){
		stopFlag = true;
	} else if( (sysYmd == '2016/10/30' && sysHms > '22:00:00') || (sysYmd == '2017/01/04' && sysHms < '09:30:00') ){
		stopFlag = true;
	} else if(sysYmd >= '2016/12/30' && sysYmd <= '2016/12/31'){
		stopFlag = true;
	}

	if(stopFlag){
		document.write("<META HTTP-EQUIV='Refresh' content='0;URL=./service_stop.html'>");
	} else {
		document.write("<META HTTP-EQUIV='Refresh' content='0;URL=/application/index.html'>");
	}

</script>

<TITLE>Home</TITLE>
</HEAD>

<BODY>

</BODY>
</HTML>

 

Of course, this solution is not the best implementation, such as:

1> The judgment of time is carried out on the client side. If there is a time difference between the client and the server side, there will be a deviation

2> Return to index.html first, and then redirect, the efficiency is not very high, and the user experience is not very good

3> The javascript code is directly exposed to the client side, which is not very safe

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326397921&siteId=291194637