mirror of https://gitee.com/y_project/RuoYi.git
commit
2af817d8dc
|
@ -0,0 +1,2 @@
|
|||
call mvn clean install -f ../pom.xml
|
||||
call mvn clean package -f ../ruoyi-admin/pom-war.xml
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>war</packaging>
|
||||
<artifactId>ruoyi-admin-war</artifactId>
|
||||
|
||||
<description>
|
||||
web服务入口(war)
|
||||
</description>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<!-- swagger2-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger2-UI-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
<!-- war 包模式特殊配置: 覆盖tomcat依赖,由外部提供 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warName>${artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.framework.config;
|
||||
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* AsyncManagerShutdownBean 类
|
||||
*
|
||||
* @Auther: cj
|
||||
* @Date: 2018/12/28
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationShutdownBean
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger("sys-user");
|
||||
|
||||
@Autowired(required = false)
|
||||
private SpringSessionValidationScheduler springSessionValidationScheduler;
|
||||
|
||||
@PreDestroy
|
||||
public void destroy()
|
||||
{
|
||||
shutdownSpringSessionValidationScheduler();
|
||||
shutdownAsyncManager();
|
||||
}
|
||||
|
||||
private void shutdownSpringSessionValidationScheduler()
|
||||
{
|
||||
if(springSessionValidationScheduler != null && springSessionValidationScheduler.isEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info("关闭会话验证任务");
|
||||
springSessionValidationScheduler.disableSessionValidation();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void shutdownAsyncManager()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info("关闭后台任务线程池");
|
||||
AsyncManager.me().shutdown(10, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,4 +40,10 @@ public class AsyncManager
|
|||
{
|
||||
executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void shutdown(long timeout, TimeUnit unit) throws Exception
|
||||
{
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(timeout,unit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,18 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
|
|||
log.debug("Stopping Spring Scheduler session validation job...");
|
||||
}
|
||||
|
||||
if(this.enabled)
|
||||
{
|
||||
executorService.shutdown();
|
||||
try
|
||||
{
|
||||
executorService.awaitTermination(10,TimeUnit.SECONDS);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
this.enabled = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue