0

This is question is about the general architecture, I do not require anyone to solve this little hack for me, although I won't be angry if someone does ;).

Suppose I have a web app that spawns standard unix processes (like Travis CI). While it seems simple enough to pick the stdout of such a process, I'd rather like to make the whole thing asynchronous (like e.g. Travis). So I thought of passing the whole output through a websocket and into some web-based terminal emulator.

However, the only emulators I could find were fully interactive (i.e. they allow for user input and thus have some custom server-side component). My goal would be to have a piece of client side code and just stuff the output into it.

So what is necessary to create a websocket, attach it to the stdout of a server-side process (preferably emulating a tty for colors and fancyness) and display a terminal client-side? I recon there are control codes to distinguish a tty from a text file and these control codes need to be encoded on the websocket somehow, but is there some documentation on this?

choeger
  • 3,562
  • 20
  • 33
  • 1
    here's [code example in Python using `twisted`](http://stackoverflow.com/a/11729467/4279) (you could attach any javascript library that convert ANSI color escape codes into corresponding HTML (upto to a complete terminal emulator)). – jfs Nov 11 '15 at 14:54

2 Answers2

0

I have done this for .NET applications. I think this may be worth for you as example.

I have a small .NET project named NLog.Contrib.Targets.WebSocketServer that is a log watcher with WebSocket and AngularJS. Basically, it broadcasts the data that is being logged through a WebSocket, and there is an AngularJS directive that shows the data. How to highlight data is more a presentation stuff, so it will depend on the framework you use. Basically, this component attaches to whatever .NET application that uses NLog as logging framework, so you can try to find some extensibility point in Travis yourself and attach your thing there.

About attaching to stdout, I have a proof of concept about a web interactive CMD.exe also in .NET, although you can disregard the stdin part. If you use Mono, probably is the same thing than in Windows.

I think this is very similar to what you are looking for. If you have a more specific question let me know.

vtortola
  • 34,709
  • 29
  • 161
  • 263
0

You can use STDWebsocket in order to achieve this. For examples, simply read the index.html script tag. It should solve your problem (or anyone that go through this question)

SkyzohKey
  • 755
  • 7
  • 16