This commit is contained in:
huahua
2024-07-24 11:54:20 +08:00
parent 64e4c2229b
commit 7cab85a021
4 changed files with 20 additions and 29 deletions

View File

@@ -40,9 +40,9 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/car_server?characterEncoding=utf-8&useSSL=false&serverTimeZone=GMT+8
username: root
password: 123456
url: jdbc:mysql://121.199.24.205:9104/diyouzhijia?characterEncoding=utf-8&useSSL=false&serverTimeZone=GMT+8
username: diyouzhijia
password: diyouzhijia123456
# quartz
quartz:
properties:
@@ -74,9 +74,9 @@ spring:
add-mappings: false
redis:
host: 127.0.0.1 #地址
port: 6379 #端口
password: xxxxxxxxx
host: 121.199.24.205 #地址
port: 9106 #端口
password: lxk@asLXdwxqp097762
timeout: 30000 # 连接超时时间(毫秒)
database: 1 #默认数据库
jedis:
@@ -170,3 +170,7 @@ wechat:
token: 111
aesKey: 111
webhook: 123 #机器人的key
lxk:
executor:
threadPoolSize: 12

View File

@@ -178,3 +178,6 @@ wechat:
aesKey: 111
webhook: 6869cd36-5f4b-4f40-bf16-c108a2c82edb #机器人的key
lxk:
executor:
threadPoolSize: 12

View File

@@ -188,3 +188,6 @@ wechat:
aesKey: 111
webhook: 6869cd36-5f4b-4f40-bf16-c108a2c82edb #机器人的key
lxk:
executor:
threadPoolSize: 12

View File

@@ -18,37 +18,18 @@ public class ExecutorConfig {
private static final Logger logger = LoggerFactory.getLogger(ExecutorConfig.class);
private ExecutorService executorService;
private final AtomicBoolean isShutdown = new AtomicBoolean(false);
// @Bean
// public ExecutorService executorService() {
// ExecutorService executorService = Executors.newFixedThreadPool(12);
// return executorService;
// }
// @PreDestroy
// public void shutdown() {
// executorService.shutdown(); // 不立即停止所有任务,但不再接受新任务
// }
// @Bean
// public ExecutorService executorService() {
// // 考虑根据实际情况调整线程池大小
// int threadPoolSize = Runtime.getRuntime().availableProcessors() * 2;
// return Executors.newFixedThreadPool(threadPoolSize);
// }
@Bean
public ExecutorService executorService(@Value("${executor.threadPoolSize:24}") int threadPoolSize) {
public ExecutorService executorService(@Value("${lxk.executor.threadPoolSize:12}") int threadPoolSize) {
// 考虑根据配置文件或环境变量动态调整线程池大小
// 这里的 threadPoolSize 通过 @Value 注解可以从应用的配置文件中读取,默认值为 24
// 这里的 threadPoolSize 通过 @Value 注解可以从应用的配置文件中读取,默认值为 12
return Executors.newFixedThreadPool(threadPoolSize);
}
@PreDestroy
public void shutdown() {
if (!isShutdown.getAndSet(true)) {
// 尝试更彻底地关闭线程池
// 尝试更彻底地关闭线程池
if (executorService != null) {
executorService.shutdownNow(); // 阻止新任务提交并尝试停止当前正在执行的任务
try {
// 等待所有任务完成或等待一段时间