All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bybutter.sisyphus.starter.webflux.AutoGracefulShutdownConfigurator.kt Maven / Gradle / Ivy

There is a newer version: 2.1.22
Show newest version
package com.bybutter.sisyphus.starter.webflux

import org.springframework.boot.SpringApplication
import org.springframework.boot.env.EnvironmentPostProcessor
import org.springframework.boot.web.server.Shutdown
import org.springframework.core.env.ConfigurableEnvironment
import org.springframework.core.env.PropertiesPropertySource
import java.util.Properties

class AutoGracefulShutdownConfigurator : EnvironmentPostProcessor {
    override fun postProcessEnvironment(environment: ConfigurableEnvironment, application: SpringApplication) {
        if (environment.containsProperty("server.shutdown")) return

        environment.propertySources.addLast(
            PropertiesPropertySource(
                "AutoGracefulShutdownConfiguration",
                Properties().apply {
                    this["server.shutdown"] = Shutdown.GRACEFUL.name
                }
            )
        )
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy