Skip to content

Commit e8ccb57

Browse files
committed
feat(tty): 增加多平台启动gotty
1 parent 8dc1d84 commit e8ccb57

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

internal/server/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ func (e *KubePiSerer) setWebkubectlProxy() {
205205

206206
func (e *KubePiSerer) bootstrap() *KubePiSerer {
207207
e.Application = iris.New()
208-
//e.Application.Use(iris.Compression)
209208
e.setUpStaticFile()
210209
e.setUpConfig()
211210
e.setUpLogger()
@@ -215,6 +214,7 @@ func (e *KubePiSerer) bootstrap() *KubePiSerer {
215214
e.setUpErrHandler()
216215
e.setWebkubectlProxy()
217216
e.runMigrations()
217+
e.startTty()
218218
return e
219219
}
220220

internal/server/tty_darwin.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// +build darwin
2+
3+
package server
4+
5+
import (
6+
"os"
7+
"os/exec"
8+
)
9+
10+
func (e *KubePiSerer) startTty() {
11+
cmd := "/Users/shenchenyang/go/bin/gotty"
12+
params := []string{"--permit-write", "bash", "init-kube.sh"}
13+
go func() {
14+
c := exec.Command(cmd, params...)
15+
c.Stdout = os.Stdout
16+
c.Stderr = os.Stderr
17+
if err := c.Run(); err != nil {
18+
e.logger.Error(err)
19+
}
20+
}()
21+
22+
}

internal/server/tty_linux.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// +build linux
2+
3+
package server
4+
5+
func (e *KubePiSerer) startTty() {
6+
cmd := "gotty"
7+
params := []string{"--permit-write", "bash", "unshare", "--fork", "--pid", "--mount-proc", "--mount", "init-kube.sh"}
8+
go func() {
9+
c := exec.Command(cmd, params...)
10+
c.Stdout = os.Stdout
11+
c.Stderr = os.Stderr
12+
if err := c.Run(); err != nil {
13+
e.logger.Error(err)
14+
}
15+
}()
16+
}

0 commit comments

Comments
 (0)