serverless-java-container icon indicating copy to clipboard operation
serverless-java-container copied to clipboard

Spring boot application doesn't restart every time

Open RAJMODI038 opened this issue 4 years ago • 2 comments

Not sure this is right place for this query.

I'm using lambda Spring Boot application with multiple aliases. Once it gets triggered very first time it loads spring boot application context but afterward it uses the same context without being reloaded.

Can anyone help me with how to reload Application every time? I don't care about overhead time to load the application. I'm confused how this serverless application gets the same node of the previous run!

RAJMODI038 avatar Apr 28 '20 13:04 RAJMODI038

Hi @RAJMODI038 - reloading the context each time is a pretty expensive operation - ie your handler will be slow. Nevertheless, it is something you can do by creating the instance of container handler inside the handleRequest method, not in the constructor of the Lambda handler class.

Out of curiosity, why do you want to reload the context for each request?

sapessi avatar Apr 28 '20 22:04 sapessi

Thanks @sapessi I've multiple aliases for single lambda and all are pointing to the same $latest version. I wanted to restart every time only to run for different profiles. It'll use configurations of 1st profile to all other aliases if it doesn't get restarted. For workaround, I'll publish individual versions for each alias instead of single $LATEST.

RAJMODI038 avatar Apr 29 '20 06:04 RAJMODI038