Skip to content

Commit

Permalink
fix: Fixed concurrent jobs reading from config
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanFreestone committed Oct 3, 2024
1 parent 76e7fe9 commit 75a8bdc
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,21 @@ order by pj.dateCreated
@PostConstruct
void init() {
// Set up the Executor
if ( grailsApplication.config.concurrentJobsGlobal instanceof Integer && grailsApplication.config.concurrentJobsGlobal > 0 )
CONCURRENT_JOBS_GLOBAL = grailsApplication.config.concurrentJobsGlobal;
try {
def concurrentJobsGlobalConfig = grailsApplication.config.getProperty('concurrentJobsGlobal', int);
if (concurrentJobsGlobalConfig > 0) {
CONCURRENT_JOBS_GLOBAL = concurrentJobsGlobalConfig;
}
} catch (Exception e) {
log.error("Failed to read concurrentJobsGlobal from config: ${e}")
}

log.info("Configured jobConcurrency: ${CONCURRENT_JOBS_GLOBAL}")
// Base the number of small jobs executable on the limit imposed on the default runner.
taskConcurrency = CONCURRENT_JOBS_GLOBAL * 2

// SO: This is not ideal. We don't want to limit jobs globally to 1 ideally. It should be
log.info("Configured taskConcurrency: ${taskConcurrency}")

// SO: This is not ideal. We don't want to limit jobs globally to 1 ideally. It should be
// 1 per tenant, but that will involve implementing custom handling for the queue and executor.
// While we only have 1 tenant, this will suffice.
executorSvc = new ThreadPoolExecutor(
Expand All @@ -111,7 +119,7 @@ order by pj.dateCreated
5,
TimeUnit.SECONDS, // Makes the above wait time in 'seconds'
new LinkedBlockingQueue<Runnable>() // Blocking queue
)
)

// Raise an event to say we are ready.
notify('jobs:job_runner_ready')
Expand Down

0 comments on commit 75a8bdc

Please sign in to comment.