Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push live terminal output to upstream #1

Open
hsntgm opened this issue Mar 16, 2023 · 1 comment
Open

Push live terminal output to upstream #1

hsntgm opened this issue Mar 16, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@hsntgm
Copy link
Member

hsntgm commented Mar 16, 2023

Folks, when the user starts a scan, service is waiting for read buffersize, only after flush() It writes process stdout to OutputStream. In long waiting scans, that causes client thinks the process is lost or drop-in timeout. We need to push terminal process live stdout to client to keep interaction. Playing with read buffersize not doing well.

Current behaviour:

RkdaU

Expected behaviour:

EXu8O

Here the blamed lines that we need to figure out. Any opinion?

private Response getStreamResponse(List<String> cmd) throws IOException {
log.info("command: " + String.join(" ", cmd));
Process process = new ProcessBuilder().command(cmd).redirectErrorStream(true).start();
return Response.ok((StreamingOutput) outputStream -> copyStream(process.getInputStream(), outputStream)).build();
}
private void copyStream(InputStream source, OutputStream target) throws IOException {
byte[] buf = new byte[1*8];
int length;
while ((length = source.read(buf)) > 0) {
target.write(buf, 0, length);
target.flush();
}
}

return getStreamResponse(cmd);

@hsntgm hsntgm added the enhancement New feature or request label Mar 16, 2023
@hsntgm hsntgm self-assigned this Mar 16, 2023
@hsntgm
Copy link
Member Author

hsntgm commented Mar 18, 2023

It seems here we need websocket, session, persistent stream @psaux-it/development .
This simple Request - Response code is not adjustable to solve our issue.

@hsntgm hsntgm added this to the Websocket milestone Mar 19, 2023
@hsntgm hsntgm assigned dupdup and unassigned hsntgm Mar 19, 2023
@hsntgm hsntgm pinned this issue Mar 19, 2023
@dupdup dupdup removed their assignment Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants