From 22a1b7cb52e5dcf17a39f350aeea83a891003a77 Mon Sep 17 00:00:00 2001 From: lack <598223084@qq.com> Date: Mon, 25 Oct 2021 13:55:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9windows=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E8=BF=9B=E7=A8=8B=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/service/gpm/v1/gpm.pb.vine.go | 4 +- api/types/gpm/v1/gpm.pb.go | 194 +++++++++++++++--------------- api/types/gpm/v1/gpm.proto | 4 +- cmd/gpm/pkg/exec.go | 2 +- cmd/gpm/pkg/terminal.go | 4 +- go.mod | 1 + pkg/biz/ftp.go | 2 +- pkg/biz/gpm_drawin.go | 6 +- pkg/biz/gpm_linux.go | 6 +- pkg/biz/gpm_windows.go | 12 +- pkg/biz/process.go | 21 +++- 11 files changed, 137 insertions(+), 119 deletions(-) diff --git a/api/service/gpm/v1/gpm.pb.vine.go b/api/service/gpm/v1/gpm.pb.vine.go index 279ea2e..8308b02 100644 --- a/api/service/gpm/v1/gpm.pb.vine.go +++ b/api/service/gpm/v1/gpm.pb.vine.go @@ -839,9 +839,7 @@ func NewGpmServiceOpenAPI() *registry.OpenAPI { "v1.ExecResult": ®istry.Model{ Type: "object", Properties: map[string]*registry.Schema{ - "result": ®istry.Schema{ - Type: "string", - }, + "result": ®istry.Schema{}, }, }, "v1.FileInfo": ®istry.Model{ diff --git a/api/types/gpm/v1/gpm.pb.go b/api/types/gpm/v1/gpm.pb.go index f4247cd..1b15c02 100644 --- a/api/types/gpm/v1/gpm.pb.go +++ b/api/types/gpm/v1/gpm.pb.go @@ -870,7 +870,7 @@ func (m *ExecIn) XXX_DiscardUnknown() { var xxx_messageInfo_ExecIn proto.InternalMessageInfo type ExecResult struct { - Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` } func (m *ExecResult) Reset() { *m = ExecResult{} } @@ -1034,7 +1034,7 @@ var xxx_messageInfo_TerminalIn proto.InternalMessageInfo type TerminalResult struct { Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` - Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` + Error []byte `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` IsOk bool `protobuf:"varint,4,opt,name=isOk,proto3" json:"isOk,omitempty"` } @@ -1108,87 +1108,87 @@ func init() { } var fileDescriptor_445ca262c078f1a5 = []byte{ - // 1270 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0xd7, 0xde, 0x3f, 0x79, 0x1b, 0xa5, 0x65, 0x54, 0x52, 0x13, 0xd0, 0x76, 0x65, 0xa1, - 0x6a, 0x41, 0x6d, 0xa2, 0x14, 0x84, 0x2a, 0x7a, 0x01, 0x44, 0x8a, 0x22, 0x90, 0x88, 0x26, 0x29, - 0x07, 0x84, 0x2a, 0xb9, 0xf6, 0xd4, 0x3b, 0xc4, 0xf6, 0x58, 0xe3, 0xf1, 0x2a, 0x81, 0x3b, 0x67, - 0x4e, 0x9c, 0x11, 0x27, 0x4e, 0x1c, 0xf9, 0x0c, 0x95, 0x90, 0x50, 0x8f, 0x1c, 0xa1, 0xfd, 0x22, - 0xe8, 0xcd, 0x8c, 0x63, 0x27, 0xbb, 0x49, 0x9b, 0x50, 0x4e, 0xfb, 0xde, 0xf3, 0x7b, 0x33, 0x6f, - 0xde, 0xef, 0xf7, 0xde, 0xcc, 0xc2, 0x56, 0xc2, 0xd5, 0xb4, 0x7a, 0xb4, 0x11, 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xca, 0x06, 0x35, 0x77, 0x51, 0xf7, 0x78, 0x4d, 0x91, 0x3e, 0xf9, 0xfc, 0xc9, 0x3f, 0xa3, - 0xa5, 0x27, 0xcf, 0x46, 0xce, 0xd3, 0x67, 0x23, 0xe7, 0xef, 0x67, 0x23, 0xe7, 0xc7, 0xe7, 0xa3, - 0xa5, 0xa7, 0xcf, 0x47, 0x4b, 0x7f, 0x3d, 0x1f, 0x2d, 0x7d, 0x7d, 0xfb, 0x25, 0xff, 0xa9, 0xde, - 0xd3, 0x35, 0x7b, 0xd4, 0xd3, 0x7f, 0x56, 0xdf, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x65, - 0xc5, 0x1e, 0xe1, 0x0e, 0x00, 0x00, + // 1271 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0x8e, 0xd7, 0xf6, 0xee, 0xe6, 0x6d, 0x94, 0x16, 0xab, 0xa4, 0x26, 0xa0, 0xed, 0xca, 0x42, + 0xd5, 0x82, 0xda, 0x44, 0x29, 0x08, 0x55, 0xf4, 0x02, 0x88, 0x14, 0x45, 0x20, 0x11, 0x4d, 0x52, + 0x0e, 0x08, 0x55, 0x72, 0xed, 0xa9, 0x77, 0x88, 0xed, 0xb1, 0xc6, 0xe3, 0x55, 0x02, 0x77, 0xce, + 0x9c, 0x38, 0x23, 0x4e, 0x9c, 0x38, 0xf2, 0x1b, 0x2a, 0x21, 0xa1, 0x1e, 0x39, 0x42, 0xfb, 0x47, + 0xd0, 0x9b, 0x19, 0xaf, 0xbd, 0xd9, 0x4d, 0xda, 0x84, 0x72, 0xda, 0xf7, 0xde, 0xbc, 0x37, 0xf3, + 0xe6, 0x7d, 0xdf, 0x7b, 0xe3, 0x85, 0x9d, 0x84, 0xc9, 0x49, 0xf5, 0x68, 0x2b, 0xe2, 0xd9, 0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 0x68, 0x29, 0x43, 0x21, 0x7d, 0x18, 0x59, 0x63, 0x97, 0xb4, 0x4d, + 0xe8, 0xc1, 0xf2, 0x52, 0x86, 0x69, 0x7a, 0x3f, 0x0d, 0x13, 0x7f, 0xa0, 0x3d, 0x5a, 0x26, 0xef, + 0x16, 0xbc, 0x16, 0x09, 0x1a, 0x4a, 0xc6, 0xf3, 0x43, 0x96, 0x61, 0x58, 0x56, 0xf8, 0xaf, 0xab, + 0x92, 0x2c, 0x2e, 0x78, 0x63, 0xb8, 0x52, 0x15, 0x71, 0x28, 0x69, 0xe3, 0xbb, 0xa1, 0x7c, 0x4f, + 0x9b, 0xbd, 0x9b, 0xb0, 0xae, 0x52, 0x68, 0x1c, 0xaf, 0x2b, 0xc7, 0x53, 0x56, 0x6f, 0x03, 0xba, + 0xa5, 0x0c, 0x65, 0x55, 0xfa, 0xbe, 0xba, 0x9c, 0xd1, 0x10, 0x8a, 0xac, 0x4c, 0xfc, 0x37, 0x34, + 0x14, 0x59, 0x99, 0x78, 0x37, 0xc0, 0xc1, 0x35, 0x7f, 0x53, 0x95, 0x6a, 0x50, 0x17, 0x56, 0x86, + 0x92, 0xa8, 0x85, 0xcd, 0x0f, 0xa0, 0x5f, 0x23, 0x82, 0xe1, 0x47, 0xf4, 0xc4, 0x90, 0x02, 0x45, + 0xef, 0x1a, 0xb8, 0xd3, 0x30, 0xad, 0xa8, 0x61, 0x85, 0x56, 0x3e, 0xec, 0xdc, 0xb5, 0x82, 0x12, + 0x06, 0x2d, 0x78, 0x30, 0xa3, 0x68, 0x22, 0x38, 0x97, 0x26, 0xda, 0x68, 0xb8, 0x65, 0xc5, 0x62, + 0x15, 0xee, 0x12, 0x14, 0x91, 0x54, 0x55, 0x49, 0x85, 0x6f, 0x6b, 0xea, 0xa1, 0x8c, 0x5e, 0x89, + 0x21, 0x95, 0x4b, 0x50, 0xc4, 0x83, 0x13, 0xc1, 0xab, 0xc2, 0xd0, 0x4a, 0x2b, 0xc1, 0x2f,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7, 0x69, 0x8a, 0xf4, 0xc9, 0xe7, 0x4f, 0xfe, 0x19, + 0xae, 0x3c, 0x79, 0x36, 0xb4, 0x9e, 0x3e, 0x1b, 0x5a, 0x7f, 0x3f, 0x1b, 0x5a, 0x3f, 0x3e, 0x1f, + 0xae, 0x3c, 0x7d, 0x3e, 0x5c, 0xf9, 0xeb, 0xf9, 0x70, 0xe5, 0xeb, 0xdb, 0x2f, 0xf9, 0x4f, 0xf5, + 0x9e, 0xaa, 0xd9, 0xa3, 0xae, 0xfa, 0xb3, 0xfa, 0xde, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4d, + 0x00, 0x64, 0xbf, 0xe1, 0x0e, 0x00, 0x00, } func (m *Service) XSize() (n int) { @@ -7283,7 +7283,7 @@ func (m *ExecResult) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGpm @@ -7293,23 +7293,25 @@ func (m *ExecResult) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthGpm } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthGpm } if postIndex > l { return io.ErrUnexpectedEOF } - m.Result = string(dAtA[iNdEx:postIndex]) + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -8118,7 +8120,7 @@ func (m *TerminalResult) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGpm @@ -8128,23 +8130,25 @@ func (m *TerminalResult) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthGpm } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthGpm } if postIndex > l { return io.ErrUnexpectedEOF } - m.Error = string(dAtA[iNdEx:postIndex]) + m.Error = append(m.Error[:0], dAtA[iNdEx:postIndex]...) + if m.Error == nil { + m.Error = []byte{} + } iNdEx = postIndex case 4: if wireType != 0 { diff --git a/api/types/gpm/v1/gpm.proto b/api/types/gpm/v1/gpm.proto index 0e1d6e8..c4527d5 100644 --- a/api/types/gpm/v1/gpm.proto +++ b/api/types/gpm/v1/gpm.proto @@ -226,7 +226,7 @@ message ExecIn { } message ExecResult { - string result = 1; + bytes result = 1; } message PullResult { @@ -258,6 +258,6 @@ message TerminalIn { message TerminalResult { bytes stdout = 1; bytes stderr = 2; - string error = 3; + bytes error = 3; bool isOk = 4; } \ No newline at end of file diff --git a/cmd/gpm/pkg/exec.go b/cmd/gpm/pkg/exec.go index 0aa872a..6c0c098 100644 --- a/cmd/gpm/pkg/exec.go +++ b/cmd/gpm/pkg/exec.go @@ -67,7 +67,7 @@ func execBash(c *cli.Context) error { return fmt.Errorf("%v", verrs.FromErr(err).Detail) } - fmt.Fprintln(outE, result.Result) + fmt.Fprintln(outE, string(result.Result)) return nil } diff --git a/cmd/gpm/pkg/terminal.go b/cmd/gpm/pkg/terminal.go index f50ac9c..bf6b647 100644 --- a/cmd/gpm/pkg/terminal.go +++ b/cmd/gpm/pkg/terminal.go @@ -88,8 +88,8 @@ func terminalBash(c *cli.Context) error { if err != nil { return errors.New(status.Convert(err).Message()) } - if b.Error != "" { - fmt.Fprintf(outE, b.Error) + if text := string(b.Error); text != "" { + fmt.Fprintf(outE, text) } if b.Stderr != nil { fmt.Fprintf(outE, string(b.Stderr)) diff --git a/go.mod b/go.mod index c3aa548..bd0b9d7 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,7 @@ require ( github.com/vine-io/pkg/unit v0.1.0 github.com/vine-io/plugins/logger/zap v1.1.0 github.com/vine-io/vine v1.3.2 + golang.org/x/text v0.3.5 google.golang.org/grpc v1.39.0 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b diff --git a/pkg/biz/ftp.go b/pkg/biz/ftp.go index f539125..d624cbd 100644 --- a/pkg/biz/ftp.go +++ b/pkg/biz/ftp.go @@ -246,7 +246,7 @@ func (s *sftp) Exec(ctx context.Context, in *gpmv1.ExecIn) (*gpmv1.ExecResult, e b, err := cmd.CombinedOutput() if err != nil { - return nil, verrs.InternalServerError(s.S.Name(), "exec %w: %v", err, beauty(b)) + return nil, verrs.InternalServerError(s.S.Name(), "exec %v: %v", err, beauty(b)) } out := &gpmv1.ExecResult{ diff --git a/pkg/biz/gpm_drawin.go b/pkg/biz/gpm_drawin.go index f1567bb..398a29b 100644 --- a/pkg/biz/gpm_drawin.go +++ b/pkg/biz/gpm_drawin.go @@ -25,11 +25,11 @@ package biz import ( + "bytes" "os" "os/exec" "os/user" "strconv" - "strings" "syscall" gpmv1 "github.com/vine-io/gpm/api/types/gpm/v1" @@ -170,6 +170,6 @@ func startTerminal(in *gpmv1.TerminalIn) *exec.Cmd { return cmd } -func beauty(b []byte) string { - return strings.TrimSuffix(string(b), "\n") +func beauty(b []byte) []byte { + return bytes.TrimSuffix(b, []byte("\n")) } diff --git a/pkg/biz/gpm_linux.go b/pkg/biz/gpm_linux.go index d8eac5e..dfe4a8f 100644 --- a/pkg/biz/gpm_linux.go +++ b/pkg/biz/gpm_linux.go @@ -25,11 +25,11 @@ package biz import ( + "bytes" "os" "os/exec" "os/user" "strconv" - "strings" "syscall" gpmv1 "github.com/vine-io/gpm/api/types/gpm/v1" @@ -167,6 +167,6 @@ func startTerminal(in *gpmv1.TerminalIn) *exec.Cmd { return cmd } -func beauty(b []byte) string { - return strings.TrimSuffix(string(b), "\n") +func beauty(b []byte) []byte { + return bytes.TrimSuffix(b, []byte("\n")) } diff --git a/pkg/biz/gpm_windows.go b/pkg/biz/gpm_windows.go index cae0ec9..87a7131 100644 --- a/pkg/biz/gpm_windows.go +++ b/pkg/biz/gpm_windows.go @@ -20,17 +20,21 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +//go:build windows // +build windows package biz import ( + "bytes" + "io/ioutil" "os" "os/exec" - "strings" "syscall" gpmv1 "github.com/vine-io/gpm/api/types/gpm/v1" + "golang.org/x/text/transform" + "golang.org/x/text/encoding/simplifiedchinese" ) func fillService(service *gpmv1.Service) error { @@ -89,6 +93,8 @@ func startTerminal(in *gpmv1.TerminalIn) *exec.Cmd { return cmd } -func beauty(b []byte) string { - return strings.TrimSuffix(string(b), "\r\n") +func beauty(b []byte) []byte { + reader := transform.NewReader(bytes.NewReader(bytes.TrimSuffix(b, []byte("\r\n"))), simplifiedchinese.GBK.NewEncoder()) + d, _ := ioutil.ReadAll(reader) + return d } diff --git a/pkg/biz/process.go b/pkg/biz/process.go index 578d0ec..4913a9e 100644 --- a/pkg/biz/process.go +++ b/pkg/biz/process.go @@ -290,7 +290,18 @@ func (p *Process) Stop() error { return ErrProcessNotFound } - close(p.done) + go func() { + close(p.done) + defer func() { + if e := recover(); e != nil { + log.Errorf("close %s channel", p.Name) + } + }() + }() + + if runtime.GOOS == "windows" { + return p.kill() + } return p.stop() } @@ -300,11 +311,9 @@ func (p *Process) stop() error { if err != nil { return err } - if runtime.GOOS == "windows" { - err = pr.Kill() - } else { - err = pr.Signal(syscall.SIGINT) - } + + err = pr.Signal(syscall.SIGINT) + if err != nil { return err }