From 9cb43b3d940bd3a876b1256ac7f28933c13b0fd0 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Tue, 23 May 2023 20:17:58 +0300 Subject: [PATCH] - Improve startup speed, by using a faster remote server to get the host's machine public IP. This also reduces the risk of not being able to get the public IP at all. - Set the App to gracefully shut down the WebServer and wait up to 2 minutes. - Increase the waiting time for the "PublicationsRetriever.executor" to shut down, to 2 minutes. --- .../java/eu/openaire/urls_worker/UrlsWorkerApplication.java | 2 +- src/main/java/eu/openaire/urls_worker/util/UriBuilder.java | 2 +- src/main/resources/application.properties | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/openaire/urls_worker/UrlsWorkerApplication.java b/src/main/java/eu/openaire/urls_worker/UrlsWorkerApplication.java index 17608b8..3bd1179 100644 --- a/src/main/java/eu/openaire/urls_worker/UrlsWorkerApplication.java +++ b/src/main/java/eu/openaire/urls_worker/UrlsWorkerApplication.java @@ -76,7 +76,7 @@ public class UrlsWorkerApplication { logger.info("Shutting down the threads used by \"PublicationsRetriever\"-plugin.."); PublicationsRetriever.executor.shutdown(); // Define that no new tasks will be scheduled. try { - if ( !PublicationsRetriever.executor.awaitTermination(1, TimeUnit.MINUTES) ) { + if ( !PublicationsRetriever.executor.awaitTermination(2, TimeUnit.MINUTES) ) { logger.warn("The working threads did not finish on time! Stopping them immediately.."); PublicationsRetriever.executor.shutdownNow(); } diff --git a/src/main/java/eu/openaire/urls_worker/util/UriBuilder.java b/src/main/java/eu/openaire/urls_worker/util/UriBuilder.java index 83f31ce..34a44a8 100644 --- a/src/main/java/eu/openaire/urls_worker/util/UriBuilder.java +++ b/src/main/java/eu/openaire/urls_worker/util/UriBuilder.java @@ -55,7 +55,7 @@ public class UriBuilder { { String publicIpAddress = ""; HttpURLConnection conn = null; - String urlString = "https://api.ipify.org/"; + String urlString = "https://checkip.amazonaws.com/"; try { conn = (HttpURLConnection) new URL(urlString).openConnection(); conn.setConnectTimeout(60_000); // 1 minute diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2e1b513..668e056 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,6 +15,9 @@ server.port = 1881 # Server api path server.servlet.context-path=/api +server.shutdown=graceful + +spring.lifecycle.timeout-per-shutdown-phase=2m #Input data configurations info.workerId = XX