async service shutdown

This commit is contained in:
anhefti 2019-09-05 12:53:11 +02:00
parent ec1d10b646
commit 4dfba2e392
11 changed files with 25 additions and 13 deletions

View file

@ -38,7 +38,7 @@ ENTRYPOINT exec java \
-jar seb-server-"${SEBSERVER_VERSION}"-SNAPSHOT.jar \
--server.port="${SERVER_PORT}" \
--spring.profiles.active=demo \
--spring.config.location=file:/sebserver/,classpath:/config/ \
--spring.config.location=file:/sebserver/config/,classpath:/config/ \
--spring.datasource.password="${DBSERVER_PWD}" \
--sebserver.webservice.api.admin.clientSecret="${GUICLIENT_PWD}" \
--sebserver.webservice.internalSecret="${INTERNAL_PWD}"

View file

@ -46,7 +46,7 @@ management.endpoints.web.base-path=/actuator
management.endpoints.web.exposure.include=logfile,loggers
# GUI server configuration
sebserver.gui.external.messages=file:/sebserver/messages
sebserver.gui.external.messages=file:/sebserver/config/messages
sebserver.gui.entrypoint=/gui
sebserver.gui.webservice.protocol=http
sebserver.gui.webservice.address=${server.address}

View file

@ -25,8 +25,8 @@ services:
- GUICLIENT_PWD=somePW
- INTERNAL_PWD=somePW
volumes:
- ./application-demo.properties:/sebserver/application-demo.properties
- ./messages_en.properties:/sebserver/messages_en.properties
- ./config:/sebserver/config
ports:
- 8080:8080
- 9090:9090

View file

@ -0,0 +1,3 @@
KEYSTORE_PWD=[SET_PWD]
MYSQL_ROOT_PASSWORD=[SET_PWD]
SEBSERVER_PWD=[SET_PWD]

View file

@ -8,17 +8,17 @@ services:
volumes:
- ./certs:/certs
env_file:
- secrets
- ./config/secrets
mariadb:
image: "mariadb/server:10.3"
container_name: seb-server-mariadb
volumes:
- .:/etc/mysql/conf.d
- ./config:/etc/mysql/conf.d
- ./certs:/etc/mysql/certs
- seb-server-mariadb-data:/var/lib/mysql
env_file:
- secrets
- ./config/secrets
ports:
- 3306:3306
networks:
@ -34,14 +34,14 @@ services:
- GIT_TAG=
- SEBSERVER_VERSION=0.4.1-beta-SNAPSHOT
container_name: seb-server
volumes:
- ./config:/sebserver/config
- ./certs:/certs
env_file:
- secrets
- ./config/secrets
environment:
- ADDITIONAL_DNS=dns:127.0.0.1,dns:seb-server
volumes:
- ./application-prod.properties:/sebserver/application-prod.properties
- ./certs:/certs
- ./secrets:/sebserver/secrets
ports:
- 443:443
- 80:8080

View file

@ -42,7 +42,7 @@ ENTRYPOINT exec java \
# -Dcom.sun.management.jmxremote.authenticate=false \
-jar seb-server-"${SEBSERVER_VERSION}".jar \
--spring.profiles.active=prod \
--spring.config.location=file:/sebserver/,classpath:/config/ \
--spring.config.location=file:/sebserver/config/,classpath:/config/ \
--sebserver.certs.password="${KEYSTORE_PWD}" \
--sebserver.mariadb.password="${MYSQL_ROOT_PASSWORD}" \
--sebserver.password="${SEBSERVER_PWD}"

View file

@ -31,6 +31,7 @@ public class AsyncServiceSpringConfig implements AsyncConfigurer {
executor.setQueueCapacity(11);
executor.setThreadNamePrefix("asyncService-");
executor.initialize();
executor.setWaitForTasksToCompleteOnShutdown(true);
return executor;
}

View file

@ -14,6 +14,8 @@ import java.util.concurrent.BlockingDeque;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingDeque;
import javax.annotation.PreDestroy;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
@ -89,6 +91,12 @@ public class AsyncBatchEventSaveStrategy implements EventHandlingStrategy {
}
}
@PreDestroy
protected void shutdown() {
log.info("Reset workersRunning flag to stop worker after event queue is empty");
this.workersRunning = false;
}
@Override
public void accept(final ClientEventRecord record) {
if (!this.workersRunning) {