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

[udash] Run shell command on server through web ui #46

Closed
at15 opened this issue Jan 6, 2019 · 2 comments
Closed

[udash] Run shell command on server through web ui #46

at15 opened this issue Jan 6, 2019 · 2 comments
Assignees
Labels
depend-by/ayi dyweb/ayi is depending on go.ice example/udash universal dashboard for database pkg/httpserver HTTP server pkg/ui type/new-feature
Milestone

Comments

@at15
Copy link
Member

at15 commented Jan 6, 2019

This is similar to #41 except it's using os/exec and proxy stdin/out/err

Ref

@at15 at15 added pkg/httpserver HTTP server pkg/ui example/udash universal dashboard for database type/new-feature depend-by/ayi dyweb/ayi is depending on go.ice labels Jan 6, 2019
@at15 at15 added this to the 0.0.3 milestone Jan 6, 2019
@at15 at15 self-assigned this Jan 6, 2019
at15 added a commit that referenced this issue Jan 6, 2019
- but it seems the pty is just echo, something wrong in the order of
reader and writer etc.
at15 added a commit that referenced this issue Jan 6, 2019
- when browser sending command, it didn't contains a `/n`, so bash never
interact with it, figured it out when looking at original example from
gorilla/websocket
at15 added a commit that referenced this issue Jan 6, 2019
- what worked for single command no longer works for xterm
@at15
Copy link
Member Author

at15 commented Jan 6, 2019

the key findings are backend implements varies based on how front end interact dyweb/blog#39

  • if you send a single command as a message from client, you need to add \n and can buffer output
  • if you use xterm, you can't add \n and should NOT buffer output, xterm relies pty's echo back to show what you type and not buffering output allows it to works like a real terminal

at15 added a commit that referenced this issue Jan 6, 2019
[Partial][example][ui] Udash docker log and exec

- implemented docker log in client and dk cli #40 , it has a package for deduplex stream (stdout, stderr)
- implemented docker exec in client and dk cli #41 , need to create a new connection manually and read the response (I actually don't need to get http client's transport, I can keep the original addr and dial it directly, need a dedicated tcp connection anyway)
- implemented web terminal using xterm and gorillawebsocket #46 , it's tricky if you don't understand all the pty stuff, most examples didn't say that (maybe it's too obvious?), when use pty, you have echo for what you type, so you won't see anything when type in xterm and when it attach to socket it will send each character as a single message, and you don't need to do any buffering on server side (pty will do that), same applies to stdout, you just copy what you read and write to websocket connection (I xterm might did some buffer on that). The gorilla example was for some one off command and submit the entire command in a web form so it adds `\n` when write to pty stdin and buffer output using bufio
@at15
Copy link
Member Author

at15 commented Jan 8, 2019

image

copied from PR ...

@at15 at15 closed this as completed in 00686e0 Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
depend-by/ayi dyweb/ayi is depending on go.ice example/udash universal dashboard for database pkg/httpserver HTTP server pkg/ui type/new-feature
Projects
None yet
Development

No branches or pull requests

1 participant