mirror of
https://github.com/1Panel-dev/KubePi.git
synced 2025-12-24 13:38:10 +08:00
feat(tty): 增加多平台启动gotty
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
22
internal/server/tty_darwin.go
Normal file
22
internal/server/tty_darwin.go
Normal 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)
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
16
internal/server/tty_linux.go
Normal file
16
internal/server/tty_linux.go
Normal 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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user