Skip to content

Commit

Permalink
1.修复登录失效跳转登录页问题
Browse files Browse the repository at this point in the history
2.优化启动脚本,设置启动位置变量
3.增加停止脚本
4.优化nginx.pid残留致使启动后认为nginx已启动问题
  • Loading branch information
lovexy-fun committed Aug 23, 2022
1 parent 2769108 commit 9aa1f10
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ hs_err_pid*
/reverse-proxy.iml
/target/
/.idea/
/nginx/logs/nginx.pid
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fun.lovexy</groupId>
<artifactId>reverse-proxy</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -81,6 +81,7 @@
</dependencies>

<build>
<finalName>reverse-proxy</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class LoginInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Object user = request.getSession().getAttribute("user");
if (null == user) {
response.sendRedirect("/login");
response.sendRedirect("/login?redirect=/login");
return false;
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ admin:
password: admin

nginx:
home: E:\ProjectSpace\IDEAProjects\reverse-proxy\nginx
home: ${BASEPATH}nginx

server:
port: 8999

spring:
datasource:
url: jdbc:sqlite:E:\ProjectSpace\IDEAProjects\reverse-proxy\reverse-proxy.db
url: jdbc:sqlite:${BASEPATH}reverse-proxy.db
driver-class-name: org.sqlite.JDBC
jackson:
time-zone: GMT+8
Expand All @@ -29,7 +29,7 @@ spring:

logging:
level:
fun.lovexy.reverseproxy: debug
fun.lovexy.reverseproxy: info
file:
path: logs

Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/static/js/common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
$(function () {
redirect()
})

/**
* 重定向
*/
function redirect() {
var params = getUrlParams();
var redirectUri = params['redirect']
if (redirectUri != undefined && redirectUri != null && redirectUri.length != 0) {
top.location.href = redirectUri;
}
}

/**
* ajax post请求
* @param url
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
{{# } else { }}
<button class="layui-btn layui-btn-sm" onclick="startNginx()">启动Nginx</button>
{{# } }}
<a href="/" style="margin: 5px;">返回查看页面</a>
</script>
<script type="text/html" id="statusTpl" th:inline="none">
{{# if (d.status == 0) { }}
Expand Down
9 changes: 8 additions & 1 deletion start.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
@echo off
start javaw -Xms300m -Xmx300m -XX:CompressedClassSpaceSize=256M -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -jar reverse-proxy-1.0.0-SNAPSHOT.jar --spring.config.location=application.yml --basepath=%~dp0
set BASEPATH=%~dp0
set PIDFILE=%BASEPATH%nginx\logs\nginx.pid
if exist %PIDFILE% (
del %PIDFILE%
)
set JAR=reverse-proxy.jar
set JVM_ARGS=-Xms300m -Xmx300m -XX:CompressedClassSpaceSize=256M -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m
start javaw %JVM_ARGS% -jar %JAR%
8 changes: 8 additions & 0 deletions stop.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
for /f "tokens=1" %%i in ('jps -l ^| findstr reverse-proxy.jar') do (
taskkill /f /pid %%i /t
)
set PIDFILE=%~dp0nginx\logs\nginx.pid
if exist %PIDFILE% (
del %PIDFILE%
)

0 comments on commit 9aa1f10

Please sign in to comment.