in jetbrains-core/src/software/aws/toolkits/jetbrains/services/clouddebug/execution/steps/AttachDebuggers.kt [54:108]
override fun execute(
context: Context,
stepEmitter: StepEmitter,
ignoreCancellation: Boolean
) {
val startTime = Instant.now()
var result = Result.Succeeded
try {
val debuggerAttacher = DebuggerSupport.debuggers()[containerOptions.platform]
?: throw IllegalStateException(
message(
"cloud_debug.step.attach_debugger.unknown_platform",
containerOptions.platform
)
)
val debugPorts = SetUpPortForwarding.getDebugPortsForContainer(context, containerName)
val attachDebuggerFuture = debuggerAttacher.attachDebugger(context, containerName, containerOptions, environment, debugPorts, stepName)
val descriptor = attachDebuggerFuture.get()
var stdoutLogsHandler: ProcessHandler? = null
var stderrLogsHandler: ProcessHandler? = null
runInEdt {
descriptor?.runnerLayoutUi?.let {
val console = debuggerAttacher.getConsoleView(environment, it)
stdoutLogsHandler = tailContainerLogs(context, console, false)
stderrLogsHandler = tailContainerLogs(context, console, true)
}
}
// This should block so that the run config does not complete until debuggers die, or we can kill all from the stop command
descriptor?.processHandler?.let {
waitForDebuggerToDisconnect(it, context)
// debugger has disconnected so we should stop tailing logs, safe access is needed due to initiliazation requirements
ApplicationManager.getApplication().executeOnPooledThread {
Thread.sleep(5000)
stdoutLogsHandler?.destroyProcess()
stderrLogsHandler?.destroyProcess()
}
} ?: throw IllegalStateException(message("cloud_debug.step.attach_debugger.failed"))
} catch (e: ExecutionException) {
result = Result.Failed
throw e.cause ?: e
} finally {
ClouddebugTelemetry.attachDebugger(
project = context.getAttribute(Context.PROJECT_ATTRIBUTE),
result = result,
workflowToken = context.workflowToken,
cloudDebugPlatform = CloudDebugPlatform.from(containerOptions.platform.name),
value = Duration.between(startTime, Instant.now()).toMillis().toDouble(),
createTime = startTime
)
}
}