Skip to content

Commit

Permalink
Add exec-agent (eclipse-che#2163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhenii Voevodin committed Dec 8, 2016
1 parent 4c587d5 commit ab9b094
Show file tree
Hide file tree
Showing 93 changed files with 15,051 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ config/

# Compiled source #
###################
*.com
!*.com/
*.class
*.dll
*.exe
Expand Down
24 changes: 12 additions & 12 deletions assembly/assembly-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
<artifactId>assembly-wsmaster-war</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>exec-agent</artifactId>
<type>tar.gz</type>
<classifier>linux_amd64</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>exec-agent</artifactId>
<type>tar.gz</type>
<classifier>linux_arm7</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-stacks</artifactId>
Expand All @@ -62,18 +74,6 @@
<artifactId>che-tomcat8-slf4j-logback</artifactId>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.eclipse.che.lib</groupId>
<artifactId>che-websocket-terminal</artifactId>
<type>tar.gz</type>
<classifier>linux_amd64</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che.lib</groupId>
<artifactId>che-websocket-terminal</artifactId>
<type>tar.gz</type>
<classifier>linux_arm7</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-sdk-tools</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions assembly/assembly-main/src/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<outputDirectory>lib/linux_amd64/terminal</outputDirectory>
<outputFileNameMapping>websocket-terminal-linux_amd64.tar.gz</outputFileNameMapping>
<includes>
<include>org.eclipse.che.lib:che-websocket-terminal:tar.gz:linux_amd64</include>
<include>org.eclipse.che:exec-agent:tar.gz:linux_amd64</include>
</includes>
</dependencySet>
<dependencySet>
Expand All @@ -79,7 +79,7 @@
<outputDirectory>lib/linux_arm7/terminal</outputDirectory>
<outputFileNameMapping>websocket-terminal-linux_arm7.tar.gz</outputFileNameMapping>
<includes>
<include>org.eclipse.che.lib:che-websocket-terminal:tar.gz:linux_arm7</include>
<include>org.eclipse.che:exec-agent:tar.gz:linux_arm7</include>
</includes>
</dependencySet>
<dependencySet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ protected void configure() {

bindConstant().annotatedWith(Names.named("machine.ws_agent.run_command"))
.to("export JPDA_ADDRESS=\"4403\" && ~/che/ws-agent/bin/catalina.sh jpda run");
bindConstant().annotatedWith(Names.named("machine.terminal_agent.run_command"))
.to("$HOME/che/terminal/che-websocket-terminal -addr :4411 -cmd ${SHELL_INTERPRETER} -static $HOME/che/terminal/");
bind(org.eclipse.che.api.workspace.server.WorkspaceValidator.class)
.to(org.eclipse.che.api.workspace.server.DefaultWorkspaceValidator.class);

Expand Down
2 changes: 2 additions & 0 deletions exec-agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
logs/
exec-agent
59 changes: 59 additions & 0 deletions exec-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Summary
---
Golang based server for executing commands and streaming process output logs,
also websocket-terminal.


Requirements
--
- golang 1.6+


Docs
---
- jsonrpc2.0 based [Webscoket API](docs/ws_api.md)
- jsonrpc2.0 based [Events](docs/events.md)
- [REST API](docs/rest_api.md)

Development
---

##### Link the sources to standard go workspace

```bash
export CHE_PATH=~/code/che
mkdir $GOPATH/src/github.com/eclipse/che -p
ln -s $CHE_PATH/exec-agent/src $GOPATH/src/github.com/eclipse/che/exec-agent
```

##### Install godep
```bash
go get github.com/tools/godep
```

##### Get all dependencies

```bash
cd $GOPATH/src/github.com/eclipse/che/exec-agent
$GOPATH/bin/godep restore
```

That's it, `$GOPATH/src/github.com/eclipse/che/exec-agent` project is ready.

##### Building linked project

```bash
cd $GOPATH/src/github.com/eclipse/che/exec-agent && go build
```

##### Running linked project tests

```bash
cd $GOPATH/src/github.com/eclipse/che/exec-agent && go test ./...
```

##### Formatting linked project sources

```bash
cd $GOPATH/src/github.com/eclipse/che/exec-agent && go fmt ./...
```
98 changes: 98 additions & 0 deletions exec-agent/docs/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Events
===
Messages sent via websocket connections to clients

Channel Events
---

#### Connected

The first event in the channel, published when client successfully connected to the exec-agent.

```json
{
"jsonrpc": "2.0",
"method": "connected",
"params": {
"time": "2016-09-24T16:40:05.098478609+03:00",
"channel": "channel-1",
"text": "Hello!"
}
}
```

Process Events
---

#### Process started

Published when process is successfully started.
This is the first event from all the events produced by process,
it appears only once for one process

```json
{
"jsonrpc": "2.0",
"method": "process_started",
"params": {
"time": "2016-09-24T16:40:55.930743249+03:00",
"pid": 1,
"nativePid": 22164,
"name": "print",
"commandLine": "printf \"\n1\n2\n3\""
}
}
```

#### STDOUT event

Published when process writes to stdout.
One stdout event describes one output line

```json
{
"jsonrpc": "2.0",
"method": "process_stdout",
"params": {
"time": "2016-09-24T16:40:55.933255297+03:00",
"pid": 1,
"text": "Starting server..."
}
}
```

#### STDERR event

Published when process writes to stderr.
One stderr event describes one output line

```json
{
"jsonrpc": "2.0",
"method": "process_stderr",
"params": {
"time": "2016-09-24T16:40:55.933255297+03:00",
"pid": 1,
"text": "sh: ifconfig: command not found"
}
}
```

#### Process died

Published when process is done, or killed. This is the last event from the process,
it appears only once for one process

```json
{
"jsonrpc": "2.0",
"method": "process_died",
"params": {
"time": "2016-09-24T16:40:55.93354086+03:00",
"pid": 1,
"nativePid": 22164,
"name": "print",
"commandLine": "printf \"\n1\n2\n3\""
}
}
```
10 changes: 10 additions & 0 deletions exec-agent/docs/notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##### Websocket messages order

The order is respected
```
Message fragments MUST be delivered to the recipient in the order sent by the sender.
```
Helpful Sources
* https://tools.ietf.org/html/rfc6455 (search the sentence above)
* http://stackoverflow.com/questions/11804721/can-websocket-messages-arrive-out-of-order
* http://stackoverflow.com/questions/14287224/processing-websockets-messages-in-order-of-receiving
Loading

0 comments on commit ab9b094

Please sign in to comment.