summaryrefslogtreecommitdiffstats
path: root/lib/xdsserver
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xdsserver')
-rw-r--r--lib/xdsserver/sdk.go73
1 files changed, 13 insertions, 60 deletions
diff --git a/lib/xdsserver/sdk.go b/lib/xdsserver/sdk.go
index 633fbee..2736246 100644
--- a/lib/xdsserver/sdk.go
+++ b/lib/xdsserver/sdk.go
@@ -20,7 +20,6 @@ package xdsserver
import (
"encoding/json"
"fmt"
- "os"
"os/exec"
"path"
"strconv"
@@ -62,9 +61,6 @@ type CrossSDK struct {
scripts map[string]string
installCmd *eows.ExecOverWS
removeCmd *eows.ExecOverWS
-
- bufStdout string
- bufStderr string
}
// ListCrossSDK List all available and installed SDK (call "db-dump" script)
@@ -233,28 +229,13 @@ func (s *CrossSDK) Install(file string, force bool, timeout int, args []string,
// Create new instance to execute command and sent output over WS
s.installCmd = eows.New(s.scripts[scriptAdd], cmdArgs, sess.IOSocket, sess.ID, cmdID)
s.installCmd.Log = s.Log
+ s.installCmd.LineTimeSpan = 500 * time.Millisecond.Nanoseconds()
if timeout > 0 {
s.installCmd.CmdExecTimeout = timeout
} else {
s.installCmd.CmdExecTimeout = 30 * 60 // default 30min
}
- // FIXME: temporary hack
- s.bufStdout = ""
- s.bufStderr = ""
- SizeBufStdout := 10
- SizeBufStderr := 2000
- if valS, ok := os.LookupEnv("XDS_SDK_BUF_STDOUT"); ok {
- if valI, err := strconv.Atoi(valS); err == nil {
- SizeBufStdout = valI
- }
- }
- if valS, ok := os.LookupEnv("XDS_SDK_BUF_STDERR"); ok {
- if valI, err := strconv.Atoi(valS); err == nil {
- SizeBufStderr = valI
- }
- }
-
// Define callback for output (stdout+stderr)
s.installCmd.OutputCB = func(e *eows.ExecOverWS, stdout, stderr string) {
// paranoia
@@ -281,27 +262,18 @@ func (s *CrossSDK) Install(file string, force bool, timeout int, args []string,
}
}
- // Temporary "Hack": Buffered sent data to avoid freeze in web Browser
- // FIXME: remove bufStdout & bufStderr and implement better algorithm
- s.bufStdout += stdout
- s.bufStderr += stderr
- if len(s.bufStdout) > SizeBufStdout || len(s.bufStderr) > SizeBufStderr {
- // Emit event
- err := (*so).Emit(xsapiv1.EVTSDKManagement, xsapiv1.SDKManagementMsg{
- CmdID: e.CmdID,
- Timestamp: time.Now().String(),
- Action: xsapiv1.SdkMgtActionInstall,
- Sdk: s.sdk,
- Progress: 0, // TODO add progress
- Exited: false,
- Stdout: s.bufStdout,
- Stderr: s.bufStderr,
- })
- if err != nil {
- s.Log.Errorf("WS Emit : %v", err)
- }
- s.bufStdout = ""
- s.bufStderr = ""
+ err := (*so).Emit(xsapiv1.EVTSDKManagement, xsapiv1.SDKManagementMsg{
+ CmdID: e.CmdID,
+ Timestamp: time.Now().String(),
+ Action: xsapiv1.SdkMgtActionInstall,
+ Sdk: s.sdk,
+ Progress: 0, // TODO add progress
+ Exited: false,
+ Stdout: stdout,
+ Stderr: stderr,
+ })
+ if err != nil {
+ s.Log.Errorf("WS Emit : %v", err)
}
}
@@ -323,25 +295,6 @@ func (s *CrossSDK) Install(file string, force bool, timeout int, args []string,
return
}
- // Emit event remaining data in bufStdout/err
- if len(s.bufStderr) > 0 || len(s.bufStdout) > 0 {
- err := (*so).Emit(xsapiv1.EVTSDKManagement, xsapiv1.SDKManagementMsg{
- CmdID: e.CmdID,
- Timestamp: time.Now().String(),
- Action: xsapiv1.SdkMgtActionInstall,
- Sdk: s.sdk,
- Progress: 50, // TODO add progress
- Exited: false,
- Stdout: s.bufStdout,
- Stderr: s.bufStderr,
- })
- if err != nil {
- s.Log.Errorf("WS Emit : %v", err)
- }
- s.bufStdout = ""
- s.bufStderr = ""
- }
-
// Update SDK status
if code == 0 && exitError == nil {
s.sdk.LastError = ""