wasm change
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,6 +16,7 @@ crontask/database/
|
|||||||
crontask/export/
|
crontask/export/
|
||||||
crontask/temp
|
crontask/temp
|
||||||
crontask/crontask
|
crontask/crontask
|
||||||
|
crontask/__debug_bin.exe
|
||||||
|
|
||||||
restagent/backup/
|
restagent/backup/
|
||||||
restagent/log/
|
restagent/log/
|
||||||
@@ -23,11 +24,13 @@ restagent/upload/
|
|||||||
restagent/software/
|
restagent/software/
|
||||||
restagent/database/
|
restagent/database/
|
||||||
restagent/restagent
|
restagent/restagent
|
||||||
|
restagent/__debug_bin.exe
|
||||||
|
|
||||||
sshsvc/sshsvc
|
sshsvc/sshsvc
|
||||||
sshsvc/mmllog/
|
sshsvc/mmllog/
|
||||||
sshsvc/mmlhome/
|
sshsvc/mmlhome/
|
||||||
sshsvc/log/
|
sshsvc/log/
|
||||||
|
sshsvc/__debug_bin.exe
|
||||||
|
|
||||||
tools/loadmconf/loadmconf
|
tools/loadmconf/loadmconf
|
||||||
|
|
||||||
|
|||||||
19
.vscode/launch.json
vendored
19
.vscode/launch.json
vendored
@@ -4,6 +4,7 @@
|
|||||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "调试模式",
|
"name": "调试模式",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
@@ -11,6 +12,22 @@
|
|||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "./restagent/restagent.go",
|
"program": "./restagent/restagent.go",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"name": "调试模式restagent",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "debug",
|
||||||
|
"program": "d:/local.git/ems.agt/restagent/restagent.go",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "debug sshsvc",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "debug",
|
||||||
|
"program": "d:/local.git/ems.agt/sshsvc/sshsvc.go",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -1,3 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"go.toolsEnvVars": {
|
||||||
|
"GOARCH": "amd64",
|
||||||
|
"GOOS": "windows"
|
||||||
|
},
|
||||||
|
"go.testEnvVars": {
|
||||||
|
"GOARCH": "wasm",
|
||||||
|
"GOOS": "js"
|
||||||
|
},
|
||||||
"commentTranslate.hover.enabled": true
|
"commentTranslate.hover.enabled": true
|
||||||
}
|
}
|
||||||
45
lib/run/exec_wasm.go
Normal file
45
lib/run/exec_wasm.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
//go:build wasm
|
||||||
|
// +build wasm
|
||||||
|
|
||||||
|
package run
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"ems.agt/lib/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExecCmd(command, path string) ([]byte, error) {
|
||||||
|
log.Debug("Exec command:", command)
|
||||||
|
|
||||||
|
cmd := exec.Command("cmd", "/C", command)
|
||||||
|
cmd.Dir = path
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
log.Tracef("Exec output: %v", string(out))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("exe cmd error: ", err)
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExecOsCmd(command, os string) error {
|
||||||
|
log.Debugf("Exec %s command:%s", os, command)
|
||||||
|
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
switch os {
|
||||||
|
case "Linux":
|
||||||
|
cmd = exec.Command(command)
|
||||||
|
case "Windows":
|
||||||
|
cmd = exec.Command("cmd", "/C", command)
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
log.Tracef("Exec output: %v", string(out))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("exe cmd error: ", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user