executor

package
Version: v0.1.4-beta Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

* * @Author: xhzhang * @Date: 2019-04-25 11:13

Index

Constants

View Source
const (
	StepCheckEnv     string = "checkenv"
	StepCreateUser          = "CreateUser"
	StepCreateTmpDir        = "CreateTmpDir"
	StepGetCode             = "getcode"
	StepDeploy              = "deploy"
	StepBackup              = "backup"
	StepUpgrade             = "upgrade"
	StepRoll                = "rollback"
	StepCheck               = "check"
	StepGetPid              = "getpid"
	StepStart               = "start"
	StepStop                = "stop"
	StepRegister            = "register"
)

Variables

This section is empty.

Functions

func Get

func Get(fs *common.StoreServer, path string) (string, error)

path is a path with filename

func Kv

func Kv(ceStruct CoulsonError) string

func NewCmdError

func NewCmdError(thisCMD, thisErr string) *cmdError

func NewFileOwnerError

func NewFileOwnerError(thisfile, thisOwner, thisErr string) *fileOwnerError

func NewGetCodeError

func NewGetCodeError(thisUrl, thisErr string) *getCodeError

func NewJsonFromService

func NewJsonFromService(s Service) (string, error)

convert Service to json string

func NewPathError

func NewPathError(thisPath, thisErr string) *pathError

func Upload

func Upload(fs *common.StoreServer, src, path string) error

src is file absolute path, path is a path without filename

Types

type Client

type Client struct {
	//source filepath
	Src string

	Addr string

	Type string

	Handler FileHandler
	//the username for http basic authorization or FTP.
	// if s3 is used, Pass is AWSAccessKeyId.
	User string
	//the base64.StdEncoding.EncodeToString([]byte(password)) for http basic authorization or FTP.
	// if s3 is used, Pass is base64.StdEncoding.EncodeToString([]byte(AWSSecretAccessKey)).
	Pass string
	//RelativePath is path+file for Get
	//RelativePath is path for Upload
	RelativePath string
	// aws s3 region
	S3Region string
	// aws s3 bucket
	S3Bucket string
}

func (*Client) Get

func (c *Client) Get() (string, error)

Download

func (*Client) Upload

func (c *Client) Upload() error

Upload

type CoulsonError

type CoulsonError interface {
	error
	Kv() string
}

type Driver

type Driver struct {
	*Task
	*Service
}

func (*Driver) BackupService

func (d *Driver) BackupService(tmpdst, uploadpath string) error

Backup service dir to temporary file and upload to file server

func (*Driver) GetBinPath

func (d *Driver) GetBinPath(cmd string) (string, error)

Get the execution path of command

func (*Driver) GetCode

func (d *Driver) GetCode() (string, error)

Download code from FileServer

func (*Driver) GetMetaScript

func (d *Driver) GetMetaScript() (string, error)

Get the meta script path which will be executed

func (*Driver) ReadServiceVerion

func (d *Driver) ReadServiceVerion() (string, error)

Read the PathFile file and get the backup path in the FileServer

func (*Driver) RunCMD

func (d *Driver) RunCMD(cmdString string) error

Run the command If cmdString contains a slash, it is tried directly and the PATH is not consulted. or find the command from PATH

type FileHandler

type FileHandler interface {
	// upload file to file server
	Upload() error
	//download file from file server, it returns a dir where Stores the unzipped package
	Get() (string, error)
	// SetClient allows a filehandler to know it's client
	// in order to access client's Get&Upload functions or
	// progress tracking.
	SetClient(*Client)
}

type FtpFileHandler

type FtpFileHandler struct {
	// contains filtered or unexported fields
}

func (*FtpFileHandler) Get

func (fu *FtpFileHandler) Get() (string, error)

Download

func (*FtpFileHandler) SetClient

func (u *FtpFileHandler) SetClient(c *Client)

func (*FtpFileHandler) Upload

func (fu *FtpFileHandler) Upload() error

Upload

type HttpFileHandler

type HttpFileHandler struct {

	// HTTPClient is the http.HTTPClient to use for Get requests.
	// This defaults to a cleanhttp.DefaultClient if left unset.
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func (*HttpFileHandler) Get

func (hu *HttpFileHandler) Get() (string, error)

func (*HttpFileHandler) SetClient

func (u *HttpFileHandler) SetClient(c *Client)

func (*HttpFileHandler) Upload

func (hu *HttpFileHandler) Upload() error

type Identiy

type Identiy struct {
	TaskID      int `json:"taskid"`
	ExecutionID int `json:"executionid"`
}

Task identity

type Result

type Result struct {
	Identiy
	ReturnCode common.ExecuteReturnCode `json:"rcode"`
	ReturnMsg  string                   `json:"rmsg"`
	StepInfo   []ResultStep             `json:"rsteps"`
}

func NewResult

func NewResult() *Result

func (*Result) AppendFailedStep

func (r *Result) AppendFailedStep(stepname string, err error)

Build StepInfo

func (*Result) AppendSuccessStep

func (r *Result) AppendSuccessStep(stepname string)

func (*Result) ToJsonString

func (r *Result) ToJsonString() (string, error)

type ResultStep

type ResultStep struct {
	StepNum    int                      `json:"stepnum"`
	StepName   string                   `json:"stepname"`
	StepState  common.ExecuteReturnCode `json:"stepstate"`
	StepMsg    string                   `json:"stepmsg"`
	ResultTime int64                    `json:"steptime"`
}

type S3FileHandler

type S3FileHandler struct {
	// contains filtered or unexported fields
}

func (*S3FileHandler) Get

func (sss *S3FileHandler) Get() (string, error)

func (*S3FileHandler) SetClient

func (u *S3FileHandler) SetClient(c *Client)

func (*S3FileHandler) Upload

func (sss *S3FileHandler) Upload() error

type Service

type Service struct {
	ServiceID   string   `json:"serviceid"`
	OsUser      string   `json:"serviceosuser"`
	Dir         string   `json:"servicedir"`
	ModuleName  string   `json:"servicemodulename"`
	CodePattern []string `json:"servicecodepattern"`
	PidFile     string   `json:"servicepidfile"`
	StartCMD    string   `json:"servicestartcmd"`
	StopCMD     string   `json:"servicestopcmd"`
}

Service

func NewServiceFromJson

func NewServiceFromJson(sjson string) (Service, error)

Build a Service with ServiceID from json string

type Task

type Task struct {
	Identiy
	OP            common.OpMode `json:"serviceop"`
	CustomPattern []string      `json:"servicecustompattern"`
	RemoteCode    string        `json:"serviceremotecode"`
	UserPass      string        `json:"serviceosuserpass"`
}

Task

type User

type User struct {
	// Uid is the user ID.
	Uid int
	// Gid is the primary group ID.
	Gid int
	// Username is the login name.
	Username string
	// Name is the user's real or display name.
	Name string
	// HomeDir is the path to the user's home directory (if they have one).
	HomeDir string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL