Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yunion.io/x/executor

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yunion.io/x/executor

  • v0.0.0-20241205080005-48f5b1212256
  • Go
  • Socket score

Version published
Created
Source

remote cmds exec tool base on grpc

new executor server

    grpcServer := grpc.NewServer()
    // register server.Executor
    apis.RegisterExecutorServer(grpcServer, &server.Executor{})
    // new tcp server
    listener, err := net.Listen("unix", socketPath)
    if err != nil {
        log.Fatalln(err)
    }
    defer listener.Close()
    err = grpcServer.Serve(listener)
    if err != nil {
        log.Fatalln(err)
    }

executor client

same interface with os/exec: Run, Start, Wait, Output, CombinedOutput StdinPipe, StdoutPipe, StderrPipe

    client.Command("pwd").Run()
    client.Command("pwd").Output()
    client.Command("pwd").CombinedOutput()

different error handle

  • get exit code
func GetExitStatus(err error) (int, bool) {
    if exiterr, ok := err.(*client.ExitError); ok {
        ws := exiterr.Sys().(syscall.WaitStatus)
        return ws.ExitStatus(), true
    } else {
        return 0, false
    }
}
err := client.Command("pwd").Run()
exitStatus, ok := GetExitStatus(err)
  • kill process
cmd := client.Command("pwd")
// ......
err := cmd.Kill()

FAQs

Package last updated on 05 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc