How to immediately terminate the Spring Boot Yarn container with an error

Imagine an error or exception occurs while running the Spring Boot Yarn container, and we need to kill container from itself and return an error code.

You can use @OnContainerStart annotation as mentioned in this article: https://mchesnavsky.tech/how-to-set-up-exit-code-on-spring-boot-yarn-container.

But if we need to stop the container immediately, we just need to call:

System.exit(1);

– where parameter is the error code. The container will immediately stop, and the specified error code will be sent to the AppMaster.

P.S. if you receive another error code in AppMaster, read the article carefully: https://mchesnavsky.tech/why-the-appmaster-receives-a-different-error-code-from-the-container-spring-boot-yarn.

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *