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

Add exec-agent #2163

Merged
merged 1 commit into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need .com files ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we don't but we need to keep vendor/github.com directory

Copy link
Contributor

@benoitf benoitf Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to authorize directories with *com)
!*.com/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll fix it thank you

*.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