feat(tty): 增加多平台启动gotty

This commit is contained in:
Aaron3S
2021-09-29 19:00:48 +08:00
parent 8dc1d84506
commit e8ccb57d01
3 changed files with 39 additions and 1 deletions

View File

@@ -205,7 +205,6 @@ func (e *KubePiSerer) setWebkubectlProxy() {
func (e *KubePiSerer) bootstrap() *KubePiSerer {
e.Application = iris.New()
//e.Application.Use(iris.Compression)
e.setUpStaticFile()
e.setUpConfig()
e.setUpLogger()
@@ -215,6 +214,7 @@ func (e *KubePiSerer) bootstrap() *KubePiSerer {
e.setUpErrHandler()
e.setWebkubectlProxy()
e.runMigrations()
e.startTty()
return e
}

View File

@@ -0,0 +1,22 @@
// +build darwin
package server
import (
"os"
"os/exec"
)
func (e *KubePiSerer) startTty() {
cmd := "/Users/shenchenyang/go/bin/gotty"
params := []string{"--permit-write", "bash", "init-kube.sh"}
go func() {
c := exec.Command(cmd, params...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
e.logger.Error(err)
}
}()
}

View File

@@ -0,0 +1,16 @@
// +build linux
package server
func (e *KubePiSerer) startTty() {
cmd := "gotty"
params := []string{"--permit-write", "bash", "unshare", "--fork", "--pid", "--mount-proc", "--mount", "init-kube.sh"}
go func() {
c := exec.Command(cmd, params...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
e.logger.Error(err)
}
}()
}