EmbeddedServer

Represents an embedded server that hosts an application. It's an entry point to the application and handles the lifecycle of the application engine.

Parameters

TEngine

The type of the application engine used by the server.

TConfiguration

The type of the configuration used by the engine.

Constructors

Link copied to clipboard
expect constructor(applicationProperties: ApplicationProperties, engineFactory: ApplicationEngineFactory<TEngine, TConfiguration>, engineConfigBlock: TConfiguration.() -> Unit = {})
actual constructor(applicationProperties: ApplicationProperties, engineFactory: ApplicationEngineFactory<TEngine, TConfiguration>, engineConfigBlock: TConfiguration.() -> Unit)
actual constructor(applicationProperties: ApplicationProperties, engineFactory: ApplicationEngineFactory<TEngine, TConfiguration>, engineConfigBlock: TConfiguration.() -> Unit)

Properties

Link copied to clipboard
Link copied to clipboard
expect val engine: TEngine
actual val engine: TEngine
actual val engine: TEngine
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
expect val monitor: Events

Provides events on Application lifecycle

actual val monitor: Events
actual val monitor: Events

Functions

Link copied to clipboard
expect fun EmbeddedServer<*, *>.addShutdownHook(stop: () -> Unit)

Adds automatic application shutdown hooks management. Should be used before starting the server. Once application termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never.

actual fun EmbeddedServer<*, *>.addShutdownHook(stop: () -> Unit)

Adds automatic JVM shutdown hooks management. Should be used before starting the server. Once JVM termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never.

actual fun EmbeddedServer<*, *>.addShutdownHook(stop: () -> Unit)

Adds automatic application shutdown hooks management. Should be used before starting the server. Once application termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never.

Link copied to clipboard
fun reload()

Reload application: destroy it first and then create again

Link copied to clipboard
expect fun start(wait: Boolean = false): EmbeddedServer<TEngine, TConfiguration>
Link copied to clipboard
expect fun stop(gracePeriodMillis: Long = engineConfig.shutdownGracePeriod, timeoutMillis: Long = engineConfig.shutdownGracePeriod)
actual fun stop(gracePeriodMillis: Long, timeoutMillis: Long)
fun stop(shutdownGracePeriod: Long, shutdownTimeout: Long, timeUnit: TimeUnit)
actual fun stop(gracePeriodMillis: Long, timeoutMillis: Long)