cron

package
v5.3.3-pre24 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: AGPL-3.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//NotifyDisabled 不通知
	NotifyDisabled = iota
	//NotifyIfEnd 执行结束时通知
	NotifyIfEnd
	//NotifyIfFail 执行失败时通知
	NotifyIfFail
)

Variables

View Source
var (
	// SendMail 发送Email
	// @param toEmail 收信邮箱
	// @param toUsername 收信人名称
	// @param title 邮件标题
	// @param content 邮件内容
	// @param ccList 抄送地址
	SendMail = send.Mail

	// SendMailWithID 发送Email(带ID参数)
	SendMailWithID = send.MailWithID

	// SendMailWithNoticer 发送Email(带Noticer参数)
	SendMailWithNoticer = send.MailWithNoticer

	// SendMailWithIDAndNoticer 发送Email(带ID和Noticer参数)
	SendMailWithIDAndNoticer = send.MailWithIDAndNoticer

	NewCmdRec = writer.New
)
View Source
var (

	// ErrFailure 报错:执行失败
	ErrFailure = errors.New(`Error`)
)
View Source
var (
	PoolSize = 50 //连接池容量
)

Functions

func AddJob

func AddJob(spec string, job *Job) bool

func AddSender

func AddSender(sender func(alertData *alert.AlertData) error)

AddSender 添加发信程序

func AddSystemJob

func AddSystemJob(name string, fn RunnerGetter, example string, description string)

AddSystemJob 添加系统Job

func Close

func Close()

func CmdParams

func CmdParams(command string) []string

func DeleteScriptFile added in v5.2.0

func DeleteScriptFile(id uint) error

func EmailSender

func EmailSender(alertData *alert.AlertData) error

func GetEntries

func GetEntries(size int) []cron.Entry

func GetEntryById

func GetEntryById(id uint) *cron.Entry

func HistoryJobsRunning

func HistoryJobsRunning() bool

func InitJobs

func InitJobs(ctx context.Context) error

func Initial

func Initial(sizes ...int)

func MainCron

func MainCron(mustStart bool) *cron.Cron

func OtherSender

func OtherSender(alertData *alert.AlertData) error

func Parse

func Parse(spec string) error

func Register

func Register(name string, fn RunnerGetter, example string, description string)

func RemoveJob

func RemoveJob(id uint)

func Running

func Running() bool

func SaveScriptFile added in v5.2.0

func SaveScriptFile(m *dbschema.NgingTask) error

func ScriptCommand added in v5.2.0

func ScriptCommand(id uint, command string) string

func ScriptFile added in v5.2.0

func ScriptFile(id uint) string

func Send

func Send(alertData *alert.AlertData) (err error)

Send 发送通知/信件

Types

type Job

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

Job 定义需要处理的job

func NewCommandJob

func NewCommandJob(ctx context.Context, id uint, name string, command string, dir string, env ...string) *Job

func NewJobFromTask

func NewJobFromTask(ctx context.Context, task *dbschema.NgingTask) (*Job, error)

func (*Job) Id

func (j *Job) Id() uint

func (*Job) LogData

func (j *Job) LogData() *dbschema.NgingTaskLog

func (*Job) LogID

func (j *Job) LogID() uint64

func (*Job) Name

func (j *Job) Name() string

func (*Job) Run

func (j *Job) Run()

Run 运行Job

func (*Job) Status

func (j *Job) Status() int32

type Jobx

type Jobx struct {
	Name         string
	Example      string //">funcName:param"
	Description  string
	RunnerGetter RunnerGetter
}

func (*Jobx) Register

func (j *Jobx) Register()

type OutputWriter

type OutputWriter = writer.OutputWriter

func NewOutputWriter

func NewOutputWriter(sizes ...uint64) OutputWriter

type Runner

type Runner func(timeout time.Duration) (out string, runingErr string, onRunErr error, isTimeout bool)

Runner 命令运行

type RunnerGetter

type RunnerGetter func(string) Runner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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