Skip to content

Commit

Permalink
Update debugger attach condition for functions local run (#4836)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flanker32 authored Dec 21, 2020
1 parent cf68a3b commit 253befc
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private void runFunctionCli(RunProcessHandler processHandler, File stagingFolder
process = getRunFunctionCliProcessBuilder(stagingFolder, funcPort, debugPort).start();
// Redirect function cli output to console
readInputStreamByLines(process.getInputStream(), inputLine -> {
if (isDebugMode() && StringUtils.containsIgnoreCase(inputLine, "Job host started") && !isDebuggerLaunched) {
if (isDebugMode() && isFuncInitialized(inputLine) && !isDebuggerLaunched) {
// launch debugger when func ready
isDebuggerLaunched = true;
launchDebugger(project, debugPort);
Expand All @@ -246,6 +246,11 @@ private void runFunctionCli(RunProcessHandler processHandler, File stagingFolder
process.waitFor();
}

private boolean isFuncInitialized(String input) {
return StringUtils.containsIgnoreCase(input, "Job host started") ||
StringUtils.containsIgnoreCase(input, "Listening for transport dt_socket at address");
}

private void readInputStreamByLines(InputStream inputStream, Consumer<String> stringConsumer) {
new ReadStreamLineThread(inputStream, stringConsumer).start();
}
Expand Down

0 comments on commit 253befc

Please sign in to comment.