From 5b51b3397dd01caad6233bf42583d01ac0c32118 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 1 Feb 2021 13:34:59 +0100 Subject: [PATCH] GH-638 Enhance the lifecycle of function deployemnt in s-c-f-deployer Resolves #638 --- .../FunctionDeployerConfiguration.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java index f4dd26d8c..831d10aa4 100644 --- a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java +++ b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2019 the original author or authors. + * Copyright 2019-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public class FunctionDeployerConfiguration { private static Log logger = LogFactory.getLog(FunctionDeployerConfiguration.class); @Bean - SmartLifecycle functionArchiveDeployer(FunctionDeployerProperties functionProperties, + SmartLifecycle functionArchiveUnDeployer(FunctionDeployerProperties functionProperties, FunctionRegistry functionRegistry, ApplicationArguments arguments, @Nullable MavenProperties mavenProperties) { ApplicationArguments updatedArguments = this.updateArguments(arguments); @@ -100,9 +100,17 @@ public class FunctionDeployerConfiguration { } FunctionArchiveDeployer deployer = new FunctionArchiveDeployer(archive); + if (logger.isInfoEnabled()) { + logger.info("Deploying archive: " + functionProperties.getLocation()); + } + deployer.deploy(functionRegistry, functionProperties, updatedArguments.getSourceArgs()); + if (logger.isInfoEnabled()) { + logger.info("Successfully deployed archive: " + functionProperties.getLocation()); + } + return new SmartLifecycle() { - private boolean running; + private boolean running = true; @Override public void stop() { @@ -118,14 +126,7 @@ public class FunctionDeployerConfiguration { @Override public void start() { - if (logger.isInfoEnabled()) { - logger.info("Deploying archive: " + functionProperties.getLocation()); - } - deployer.deploy(functionRegistry, functionProperties, updatedArguments.getSourceArgs()); - this.running = true; - if (logger.isInfoEnabled()) { - logger.info("Successfully deployed archive: " + functionProperties.getLocation()); - } + // no op } @Override