runner

package
v0.7.8-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParallelScp

func ParallelScp(servers []ServerInternal, srcPath string, dstPath string, mode os.FileMode) chan error

func RemoteWriteFile

func RemoteWriteFile(b []byte, dstPath string, instance ServerInternal, mode os.FileMode)

func ReturnParalleRunResult

func ReturnParalleRunResult(servers []ServerInternal, cmd string) chan ShellResult

func Run

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

func ScpFile

func ScpFile(srcPath string, dstPath string, server ServerInternal, mode os.FileMode)

远程写文件

Types

type ExecutorExternal

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

type ExecutorInternal

type ExecutorInternal struct {
	Servers []ServerInternal
	Script  string
}

func ParseExecutor

func ParseExecutor(b []byte) (ExecutorInternal, error)

ParseExecutor 执行器反序列化

func (ExecutorInternal) ParallelRun

func (executor ExecutorInternal) ParallelRun(logger *logrus.Logger) chan ShellResult

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"`
}

type ServerInternal

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

func ParseServerList

func ParseServerList(b []byte) ([]ServerInternal, error)

ParseServerList ServerList反序列化

func (ServerInternal) CommandExists

func (server ServerInternal) CommandExists(cmd string) bool

func (ServerInternal) HomeDir

func (server ServerInternal) HomeDir() string

HomeDir /root or /home/username

func (ServerInternal) InstallSoft

func (server ServerInternal) InstallSoft(installScript string) error

func (ServerInternal) MoveDirFiles

func (server ServerInternal) MoveDirFiles(srcDir string, dstDir string)

MoveDirFiles 移动目录下文件至新目录

func (ServerInternal) RemoteShellReturnStd

func (server ServerInternal) RemoteShellReturnStd(cmd string) string

func (ServerInternal) ReturnRunResult

func (server ServerInternal) ReturnRunResult(cmd string) ShellResult

func (ServerInternal) Scp

func (server ServerInternal) Scp(srcPath string, dstPath string, mode os.FileMode, showProcessBar bool) error

Scp 远程写文件

func (ServerInternal) ServerFilter

func (server ServerInternal) ServerFilter(excludes []string) []ServerInternal

ServerFilter 解析ip地址区间类型,排除excludes数组内的主机

func (ServerInternal) TailFile

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

TailFile all & real time

func (ServerInternal) WriteRemoteFile

func (server ServerInternal) WriteRemoteFile(b []byte, dstPath string, mode os.FileMode)

type ServerListExternal

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

type ServerListInternal

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

func (ServerListInternal) ServerListFilter

func (serverListInternal ServerListInternal) ServerListFilter() []ServerInternal

ServerListFilter 解析、过滤server主机列表 解析ip地址区间类型,排除excludes数组内的主机

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
}

func ReadErrorChanWithSelect

func ReadErrorChanWithSelect(ch chan ShellResult) (value ShellResult, err error)

ReadErrorChanWithSelect select结构实现通道读

func ReadWithSelect

func ReadWithSelect(ch chan ShellResult) (value ShellResult, err error)

ReadWithSelect select结构实现通道读

type ShellResultSlice

type ShellResultSlice []ShellResult

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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