task

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobStatusSchedule JobStatus = "schedule"
	JobStatusStopped  JobStatus = "stopped"

	MarkText     = "###mark###"
	ErrorText    = "[error]"
	DoneMartText = "###done###"
)
View Source
const (
	DefaultTempDate = 14 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func NewSyncBuffer

func NewSyncBuffer(fd *os.File) *syncBuffer

Types

type Job

type Job struct {
	ID int
	// contains filtered or unexported fields
}

Job is cron task or long task

func (*Job) Close

func (j *Job) Close()

func (*Job) Cmd

func (j *Job) Cmd() string

func (*Job) Name

func (j *Job) Name() string

func (*Job) Run

func (j *Job) Run()

func (*Job) Status

func (j *Job) Status() JobStatus

func (*Job) UpdateStatus

func (j *Job) UpdateStatus(status JobStatus)

type JobStatus

type JobStatus string

type Manager

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

func NewManager

func NewManager(sshManager *ssh.Manager, cfg *config.Conf) *Manager

func (*Manager) ClearLogs

func (m *Manager) ClearLogs(job *Job) error

ClearLogs 删除job的日志

func (*Manager) CronClearInstanceCache

func (m *Manager) CronClearInstanceCache()

CronClearInstanceCache clear instance cache

func (*Manager) CronClearUploadFiles

func (m *Manager) CronClearUploadFiles()

CronClearUploadFiles clear upload file

func (*Manager) CronStatusJob

func (m *Manager) CronStatusJob()

CronStatusJob 获取host状态并更新到数据库

func (*Manager) ExecJob

func (m *Manager) ExecJob(modelJob *models.Job) error

ExecJob 执行一次任务

func (*Manager) GetJob

func (m *Manager) GetJob(id int) (*Job, bool)

GetJob 从task poll获取job

func (*Manager) GetJobList

func (m *Manager) GetJobList() *utils.SafeMap

GetJobList 获取task poll对象

func (*Manager) Init

func (m *Manager) Init() *Manager

Init 启动crontab daemon, 注册全局任务, 创建日志文件夹并初始化job

func (*Manager) NewJob

func (m *Manager) NewJob(id int, name, cmd, spec, cmdType string, cmdId int, host []*models.Host) *Job

func (*Manager) NewRealJob

func (m *Manager) NewRealJob(modelJob *models.Job) (*Job, error)

NewRealJob 新建一个job

func (*Manager) NewRealJobWithRegister

func (m *Manager) NewRealJobWithRegister(modelJob *models.Job, status string) (*Job, error)

NewRealJobWithRegister 新建一个job并注册到task poll

func (*Manager) RemoveJob

func (m *Manager) RemoveJob(id int) error

RemoveJob 从task poll删除,并删除model

func (*Manager) ScheduleJob

func (m *Manager) ScheduleJob(job *Job) error

ScheduleJob 开始任务的调度

func (*Manager) StartJob

func (m *Manager) StartJob(modelJob *models.Job) error

StartJob 从models注册并启动调度

func (*Manager) StopJob

func (m *Manager) StopJob(id int) error

StopJob 从task poll删除job

func (*Manager) UnRegister

func (m *Manager) UnRegister(id int, clear bool) error

UnRegister 关闭task & 从poll删除

Jump to

Keyboard shortcuts

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