Commit ebe88bd7 by 许雪里 Committed by GitHub

Merge pull request #1104 from WEIZIBIN/fix_graceful_shutdown_callback_lose

修复优雅停机时,中断线程后,任务状态没有同步到admin
parents 8c73afa2 35bceaac
......@@ -84,6 +84,12 @@ public class XxlJobExecutor {
initRpcProvider(ip, port, appName, accessToken);
}
public void destroy(){
List<JobThread> runningThreads = new ArrayList<>(jobThreadRepository.values());
if (logger.isInfoEnabled()) {
logger.info("running threads {}", runningThreads);
}
// destory executor-server
stopRpcProvider();
......@@ -96,6 +102,15 @@ public class XxlJobExecutor {
}
jobHandlerRepository.clear();
for (JobThread runningThread : runningThreads) {
try {
// wait for all job thread push result to callback queue
runningThread.join();
} catch (InterruptedException e) {
logger.warn("interrupted while stopping {}", runningThread);
break;
}
}
// destory JobLogFileCleanThread
JobLogFileCleanThread.getInstance().toStop();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment