runner

package
v0.7.11-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParallelScp

func ParallelScp(item ScpItem) chan error

ParallelScp 并发拷贝

func RemoteRun

func RemoteRun(b []byte, logger *logrus.Logger, cmd string) error

RemoteRun 远程执行输出结果

Types

type ExecutorExternal

type ExecutorExternal struct {
	Servers  []ServerExternal `yaml:"server"`
	Excludes []string         `yaml:"excludes"`
	Script   string           `yaml:"script"`
	logrus.Logger
}

ExecutorExternal 执行器序列化对象

type ExecutorInternal

type ExecutorInternal struct {
	Servers        []ServerInternal
	Script         string
	Logger         *logrus.Logger
	OutPutRealTime bool
}

ExecutorInternal 执行器内部对象

func ParseExecutor

func ParseExecutor(b []byte, logger *logrus.Logger) (ExecutorInternal, error)

ParseExecutor 执行器反序列化

func (ExecutorInternal) ParallelRun

func (executor ExecutorInternal) ParallelRun() chan ShellResult

ParallelRun 并发执行

type InternelServersSlice

type InternelServersSlice []ServerInternal

InternelServersSlice 带有排序的server列表

func (InternelServersSlice) Len

func (servers InternelServersSlice) Len() int

func (InternelServersSlice) Less

func (servers InternelServersSlice) Less(i, j int) bool

func (InternelServersSlice) Swap

func (servers InternelServersSlice) Swap(i, j int)

type Item

type Item struct {
	Server         ServerInternal
	Cmd            string
	Logger         *logrus.Logger
	OutputRealTime bool
}

Item 执行run指令的对象

type ScpItem

type ScpItem struct {
	Servers        []ServerInternal
	SrcPath        string
	DstPath        string
	Mode           os.FileMode
	Logger         *logrus.Logger
	ShowProcessBar bool
}

ScpItem 定义跨主机拷贝属性

type ServerExternal

type ServerExternal struct {
	Host           string `yaml:"host"`
	Port           string `yaml:"port"`
	Username       string `yaml:"username"`
	Password       string `yaml:"password"`
	PrivateKeyPath string `yaml:"privateKeyPath"`
}

ServerExternal server序列化对象

type ServerInternal

type ServerInternal struct {
	Host           string
	Port           string
	Username       string
	Password       string
	PrivateKeyPath string
}

ServerInternal server内部对象

func ParseServerList

func ParseServerList(b []byte, logger *logrus.Logger) ([]ServerInternal, error)

ParseServerList ServerList反序列化

func (ServerInternal) ReturnRunResult

func (server ServerInternal) ReturnRunResult(cmd string) ShellResult

ReturnRunResult 获取执行结果

func (ServerInternal) Scp

func (server ServerInternal) Scp(item ScpItem) error

Scp 远程写文件

func (ServerInternal) TailFile

func (server ServerInternal) TailFile(path string, offset int64, whence int, stopCh <-chan struct{})

TailFile all & real time

type ServerListExternal

type ServerListExternal struct {
	Servers  []ServerExternal `yaml:"server"`
	Excludes []string         `yaml:"excludes"`
}

ServerListExternal server列表序列化对象

type ServerListInternal

type ServerListInternal struct {
	Servers  []ServerInternal
	Excludes []string
}

ServerListInternal server列表内部对象

type ShellResult

type ShellResult struct {
	Host      string `table:"主机地址"`
	Cmd       string `table:"执行语句"`
	Code      int    `table:"退出码"`
	Status    string `table:"执行状态"`
	StdOut    string `table:"执行结果"`
	Output    string `table:"标准输出"`
	StdErrMsg string
	Err       error
}

ShellResult shell执行结果

func GetResult

func GetResult(b []byte, logger *logrus.Logger, cmd string) ([]ShellResult, error)

GetResult 远程执行,获取结果

func LocalRun

func LocalRun(shell string, logger *logrus.Logger) ShellResult

LocalRun 本地执行

type ShellResultSlice

type ShellResultSlice []ShellResult

ShellResultSlice shell执行结果切片

func (ShellResultSlice) Len

func (re ShellResultSlice) Len() int

func (ShellResultSlice) Less

func (re ShellResultSlice) Less(i, j int) bool

func (ShellResultSlice) Swap

func (re ShellResultSlice) Swap(i, j int)

type WindowsErr

type WindowsErr struct {
	Errors string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL