42 lines
1.4 KiB
Java
42 lines
1.4 KiB
Java
package eu.openaire.urls_worker;
|
|
|
|
import eu.openaire.publications_retriever.PublicationsRetriever;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
import javax.annotation.PreDestroy;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@SpringBootApplication
|
|
@EnableScheduling
|
|
public class UrlsWorkerApplication {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(UrlsWorkerApplication.class);
|
|
|
|
public static void main(String[] args) {
|
|
SpringApplication.run(UrlsWorkerApplication.class, args);
|
|
}
|
|
|
|
@PreDestroy
|
|
public static void preDestroy()
|
|
{
|
|
if ( PublicationsRetriever.executor != null )
|
|
{
|
|
PublicationsRetriever.executor.shutdown(); // Define that no new tasks will be scheduled.
|
|
try {
|
|
if ( !PublicationsRetriever.executor.awaitTermination(1, TimeUnit.MINUTES) ) {
|
|
logger.warn("The working threads did not finish on time! Stopping them immediately..");
|
|
PublicationsRetriever.executor.shutdownNow();
|
|
}
|
|
} catch (InterruptedException e) {
|
|
PublicationsRetriever.executor.shutdownNow();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|