worker

package
v0.0.0-...-e9e6038 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmd

func NewCmd(cmdDir, cmdName, cmdStatement string, appName string, hosts []string, fileName string) *cmd.Cmd

NewCmd for new cmd statement

func StartWorker

func StartWorker()

StartWorker to start this agent as worker

Types

type CmdOut

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

CmdOut cmd execute out

type CmdType

type CmdType string

CmdType cmd 类型

const (
	//UPDATECODECMD 变更代码 cmd
	UPDATECODECMD CmdType = "update"
	//RELOADSERVICECMD 重启服务 cmd
	RELOADSERVICECMD CmdType = "reload"
	//CHECKSERVICECMD 检查服务 cmd
	CHECKSERVICECMD CmdType = "check"
)

type DeployJob

type DeployJob struct {
	DeployID    int    `json:"id"`
	AppID       int    `json:"app_id"`
	AppName     string `json:"app_name"`
	DeployDir   string `json:"deploy_dir"`
	CommitID    string `json:"commit_id"`
	CommitTag   string `json:"commit_tag"`
	RollbackTag string `json:"rollback_tag"`
	RollbackID  string `json:"rollback_id"`
	BinaryURL   string `json:"binary_url"`
	//一次部署多少主机
	Max int `json:"max"`
	//每个批次主机之间间隔多久
	Interval int `json:"interval"`
	//上线主机
	Hosts     []string `json:"hosts"`
	LeftHosts []string

	// 服务检查状态 0 未重启 1 重启
	Status StatusType

	UpdateCodeCmd    string `json:"update_code_cmd"`
	ReloadServiceCmd string `json:"reload_service_cmd"`
	CheckServiceCmd  string `json:"check_service_cmd"`
	CmdName          string `json:"cmd_name"`
	CmdDir           string `json:"cmd_dir"`

	sync.Mutex
	// contains filtered or unexported fields
}

DeployJob 部署任务

func NewDeployJob

func NewDeployJob(body io.Reader) *DeployJob

NewDeployJob 生成新的部署任务

func (*DeployJob) IsCheckSuccess

func (t *DeployJob) IsCheckSuccess() bool

IsCheckSuccess deployJob 包含的全部主机服务是否都变更成功

func (*DeployJob) IsCodeSuccess

func (t *DeployJob) IsCodeSuccess() bool

IsCodeSuccess deployJob 包含的全部主机代码是否都变更成功

func (*DeployJob) IsReloadSuccess

func (t *DeployJob) IsReloadSuccess() bool

IsReloadSuccess deployJob 包含的全部主机服务是否都变更成功

func (*DeployJob) UpdateCheckStatus

func (t *DeployJob) UpdateCheckStatus(hosts []string)

UpdateCheckStatus 更新主机服务变化状态

func (*DeployJob) UpdateCodeStatus

func (t *DeployJob) UpdateCodeStatus(hosts []string)

UpdateCodeStatus 更新主机代码更新状态

func (*DeployJob) UpdateReloadStatus

func (t *DeployJob) UpdateReloadStatus(hosts []string)

UpdateReloadStatus 更新主机服务变化状态

type FileLogWriter

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

FileLogWriter file log support

func (*FileLogWriter) Write

func (w *FileLogWriter) Write(out *CmdOut) (int, error)

Write for file writer

type HTTPLogWriter

type HTTPLogWriter struct {
}

HTTPLogWriter http log support

func (*HTTPLogWriter) Write

func (w *HTTPLogWriter) Write(out *CmdOut) (int, error)

Write for http writer

type JobLogWriter

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

JobLogWriter for single deploy job

func (*JobLogWriter) Close

func (w *JobLogWriter) Close(job *DeployJob)

Close for JobLogWriter file

func (*JobLogWriter) Write

func (w *JobLogWriter) Write(out *CmdOut) (int, error)

Write for JobLogWriter

type LogWriter

type LogWriter interface {
	Write(*CmdOut) (int, error)
}

LogWriter job execute log wirter

type RunningCmd

type RunningCmd struct {
	Status StatusType
	// contains filtered or unexported fields
}

RunningCmd 正在执行 cmd

type RunningJobMap

type RunningJobMap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RunningJobMap 控制同一个 app 同时只能有一个 job 在执行

func (*RunningJobMap) AddJob

func (t *RunningJobMap) AddJob(job *DeployJob)

AddJob add deploy

func (*RunningJobMap) RemoveJob

func (t *RunningJobMap) RemoveJob(job *DeployJob)

RemoveJob remove deploy job

type StatusType

type StatusType string

StatusType job status

const (
	//NEWSTATUS new status
	NEWSTATUS StatusType = "new"
	//DOINGSTATUS doing status
	DOINGSTATUS StatusType = "doing"
	//SUCCESSSTATUS success status
	SUCCESSSTATUS StatusType = "success"
	//FAILSTATUS fail status
	FAILSTATUS StatusType = "fail"
)

Jump to

Keyboard shortcuts

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