Skip to content

Commit

Permalink
Set jetty server thread names (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Mashkov committed Dec 18, 2018
1 parent b6750b1 commit 6e08fd2
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -12,18 +12,24 @@ import org.eclipse.jetty.server.handler.*
import java.lang.IllegalStateException
import java.util.concurrent.*
import java.util.concurrent.CancellationException
import java.util.concurrent.atomic.*
import javax.servlet.*
import javax.servlet.http.*
import kotlin.coroutines.*

private val JettyCallHandlerCoroutineName = CoroutineName("jetty-call-handler")

private val JettyKtorCounter = AtomicLong()

internal class JettyKtorHandler(
val environment: ApplicationEngineEnvironment,
private val pipeline: () -> EnginePipeline,
private val engineDispatcher: CoroutineDispatcher
) : AbstractHandler(), CoroutineScope {
private val executor = ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors() * 8)
private val environmentName = environment.connectors.joinToString("-") { it.port.toString() }
private val executor = ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors() * 8) { r ->
Thread(r, "ktor-jetty-$environmentName-${JettyKtorCounter.incrementAndGet()}")
}
private val dispatcher = DispatcherWithShutdown(executor.asCoroutineDispatcher())
private val multipartConfig = MultipartConfigElement(System.getProperty("java.io.tmpdir"))

Expand Down

0 comments on commit 6e08fd2

Please sign in to comment.