Skip to content

Commit

Permalink
Added config value to enable/disable Quartz scheduler. added docker c…
Browse files Browse the repository at this point in the history
…ompose cluster to test API & worker nodes config
  • Loading branch information
maallen committed Aug 15, 2023
1 parent 446350a commit d6cfa3c
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 1 deletion.
130 changes: 130 additions & 0 deletions docker/docker-compose-api-worker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
version: '2.4'
name: mojito
services:
db:
image: mysql:5.7
restart: always
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 30s
retries: 20
environment:
MYSQL_ROOT_PASSWORD: ChangeMe
MYSQL_DATABASE: mojito
MYSQL_USER: mojito
MYSQL_PASSWORD: ChangeMe
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_bin
- --max-connections=1000
worker:
deploy:
mode: replicated
replicas: 1
endpoint_mode: vip
# resources:
# limits:
# cpus: '0.50'
# memory: 500M
# reservations:
# cpus: '0.25'
# memory: 20M
healthcheck:
test: [ "CMD", "curl", "localhost:8080/" ]
interval: 5s
timeout: 10s
retries: 20
depends_on:
db:
condition: service_healthy
api:
condition: service_healthy
build:
dockerfile: docker/Dockerfile-bk8
context: ../
links:
- db
restart: always
environment:
SPRING_APPLICATION_JSON: '{
"spring.flyway.enabled": "true",
"l10n.flyway.clean" : "false",
"spring.jpa.database-platform" : "org.hibernate.dialect.MySQLDialect",
"spring.jpa.hibernate.ddl-auto" : "none",
"spring.datasource.url" : "jdbc:mysql://db:3306/mojito?characterEncoding=UTF-8&useUnicode=true",
"spring.datasource.username" : "mojito",
"spring.datasource.password" : "ChangeMe",
"spring.datasource.driverClassName" : "com.mysql.cj.jdbc.Driver",
"spring.jpa.defer-datasource-initialization" : "false",
"l10n.org.quartz.scheduler.enabled" : "true",
"l10n.org.quartz.jobStore.useProperties" : "true",
"l10n.org.quartz.scheduler.instanceId" : "AUTO",
"l10n.org.quartz.jobStore.isClustered" : "true",
"l10n.org.quartz.threadPool.threadCount" : "10",
"l10n.org.quartz.jobStore.class" : "org.quartz.impl.jdbcjobstore.JobStoreTX",
"l10n.org.quartz.jobStore.driverDelegateClass" : "org.quartz.impl.jdbcjobstore.StdJDBCDelegate",
"l10n.org.quartz.jobStore.dataSource" : "myDS",
"l10n.org.quartz.dataSource.myDS.provider" : "hikaricp",
"l10n.org.quartz.dataSource.myDS.driver" : "com.mysql.jdbc.Driver",
"l10n.org.quartz.dataSource.myDS.URL" : "jdbc:mysql://db:3306/mojito?characterEncoding=UTF-8&useUnicode=true",
"l10n.org.quartz.dataSource.myDS.user" : "mojito",
"l10n.org.quartz.dataSource.myDS.password" : "ChangeMe",
"l10n.org.quartz.dataSource.myDS.maxConnections" : "12",
"l10n.org.quartz.dataSource.myDS.validationQuery" : "select 1"
}'
api:
deploy:
mode: replicated
replicas: 1
endpoint_mode: vip
# resources:
# limits:
# cpus: '0.50'
# memory: 500M
# reservations:
# cpus: '0.25'
# memory: 20M
healthcheck:
test: [ "CMD", "curl", "localhost:8080/" ]
interval: 5s
timeout: 10s
retries: 20
depends_on:
db:
condition: service_healthy
build:
dockerfile: docker/Dockerfile-bk8
context: ../
links:
- db
ports:
- "8080:8080"
restart: always
environment:
SPRING_APPLICATION_JSON: '{
"spring.flyway.enabled": "true",
"l10n.flyway.clean" : "false",
"spring.jpa.database-platform" : "org.hibernate.dialect.MySQLDialect",
"spring.jpa.hibernate.ddl-auto" : "none",
"spring.datasource.url" : "jdbc:mysql://db:3306/mojito?characterEncoding=UTF-8&useUnicode=true",
"spring.datasource.username" : "mojito",
"spring.datasource.password" : "ChangeMe",
"spring.datasource.driverClassName" : "com.mysql.cj.jdbc.Driver",
"spring.jpa.defer-datasource-initialization" : "false",
"l10n.org.quartz.scheduler.enabled" : "false",
"l10n.org.quartz.jobStore.useProperties" : "true",
"l10n.org.quartz.scheduler.instanceId" : "AUTO",
"l10n.org.quartz.jobStore.isClustered" : "true",
"l10n.org.quartz.threadPool.threadCount" : "10",
"l10n.org.quartz.jobStore.class" : "org.quartz.impl.jdbcjobstore.JobStoreTX",
"l10n.org.quartz.jobStore.driverDelegateClass" : "org.quartz.impl.jdbcjobstore.StdJDBCDelegate",
"l10n.org.quartz.jobStore.dataSource" : "myDS",
"l10n.org.quartz.dataSource.myDS.provider" : "hikaricp",
"l10n.org.quartz.dataSource.myDS.driver" : "com.mysql.jdbc.Driver",
"l10n.org.quartz.dataSource.myDS.URL" : "jdbc:mysql://db:3306/mojito?characterEncoding=UTF-8&useUnicode=true",
"l10n.org.quartz.dataSource.myDS.user" : "mojito",
"l10n.org.quartz.dataSource.myDS.password" : "ChangeMe",
"l10n.org.quartz.dataSource.myDS.maxConnections" : "12",
"l10n.org.quartz.dataSource.myDS.validationQuery" : "select 1"
}'
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -32,6 +33,9 @@ public class QuartzConfig {
@Autowired(required = false)
List<JobDetail> jobDetails = new ArrayList<>();

@Value("${l10n.org.quartz.scheduler.enabled:true}")
boolean startScheduler;

/**
* Starts the scheduler after having removed outdated trigger/jobs
*
Expand All @@ -40,7 +44,10 @@ public class QuartzConfig {
@PostConstruct
void startScheduler() throws SchedulerException {
removeOutdatedJobs();
scheduler.startDelayed(2);
if (startScheduler) {
logger.info("Starting scheduler");
scheduler.startDelayed(2);
}
}

void removeOutdatedJobs() throws SchedulerException {
Expand Down

0 comments on commit d6cfa3c

Please sign in to comment.