Shutdown background jobs when pressing ctrl+c

This commit is contained in:
Friendseeker 2024-11-26 15:36:59 -08:00 committed by Jiahui (Jerry) Tan
parent aae3dbd3b7
commit 9494033bd6
2 changed files with 10 additions and 0 deletions

View File

@ -531,6 +531,7 @@ object EvaluateTask {
log.warn("Canceling execution...")
RunningProcesses.killAll()
ConcurrentRestrictions.cancelAll()
DefaultBackgroundJobService.stop()
shutdownImpl(true)
}
}

View File

@ -508,6 +508,15 @@ private[sbt] object DefaultBackgroundJobService {
backgroundJobServices.values.forEach(_.shutdown())
backgroundJobServices.clear()
}
private[sbt] def stop(): Unit = {
backgroundJobServices
.values()
.forEach(jobService => {
jobService.jobs.foreach(jobService.stop)
})
}
private[sbt] lazy val backgroundJobServiceSetting: Setting[_] =
(GlobalScope / Keys.bgJobService) := {
val path = (GlobalScope / sbt.Keys.bgJobServiceDirectory).value