task

package
v0.0.0-...-2a34ce9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_WAIT     = "wait"
	STATUS_READY    = "ready"
	STATUS_SUSPEND  = "suspend"
	STATUS_RUNNING  = "running"
	STATUS_COMPLETE = "complete"
	STATUS_CANCEL   = "cancel"
	STATUS_FAILED   = "failed"
)
View Source
const (
	TASK_TYPE_APPSTORE = "appstore"
	TASK_TYPE_EMAIL    = "email"
	TASK_TYPE_HTTP     = "http"
)
View Source
const (
	INSTALL_RUNNING_KEY = "install_task_running"
)

Variables

View Source
var TASK_SERV_SOCK = "/var/run/zap_task"
View Source
var ZAP_MIRROR_URL = "https://mirrors.zap.cn/zap"

Functions

func AddJob

func AddJob(job ZapJobInterface)

func AppInstallAction

func AppInstallAction(c *gin.Context)

func AppUninstallAction

func AppUninstallAction(c *gin.Context)

func CancelTask

func CancelTask(id uint) bool

func LoadTask

func LoadTask(status ...string)

func RegisterRouter

func RegisterRouter(r *gin.RouterGroup)

func StartServer

func StartServer(ctx context.Context)

func StartTaskQueue

func StartTaskQueue()

func StartTaskScheduler

func StartTaskScheduler()

func SystemdAction

func SystemdAction(c *gin.Context)

func TaskCancelAction

func TaskCancelAction(c *gin.Context)

func UpgradeAction

func UpgradeAction(c *gin.Context)

func UpgradeZapd

func UpgradeZapd()

Types

type AppStoreJob

type AppStoreJob struct {
	Ctx              context.Context
	TaskData         *models.ZapTask
	Cmd              string
	AppId            int    //apps ID
	AppStoreUniqueId string // appstore unique id
	AppStoreId       int    // appstore id
}

func (*AppStoreJob) Clean

func (b *AppStoreJob) Clean()

func (*AppStoreJob) Execute

func (b *AppStoreJob) Execute() (err error)

type BashJob

type BashJob struct {
	Ctx context.Context
}

func (*BashJob) Execute

func (b *BashJob) Execute() error

type EmailJob

type EmailJob struct {
	Ctx context.Context
}

func (*EmailJob) Execute

func (b *EmailJob) Execute() error

type HttpJob

type HttpJob struct {
	Ctx context.Context
}

func (*HttpJob) Execute

func (b *HttpJob) Execute() error

type InstallApp

type InstallApp struct {
	ID    int
	Retry int
	C     *cron.Cron
}

type Scheduler

type Scheduler struct {
	ID    int
	Retry int
	C     *cron.Cron
}

type TaskCommand

type TaskCommand struct {
	Title     string   `json:"title"`
	Cmd       string   `json:"cmd"`
	TargetDir string   `json:"target_dir"`
	LogFile   string   `json:"log_file"`
	Args      []string `json:"args"`
	Env       []string `json:"env"`
}

type ZapJob

type ZapJob struct {
	TaskCtx    context.Context
	TaskCancel context.CancelFunc
	TaskType   string
	JobId      uint
	Cmd        string
	StartTime  int64
	EndTime    int64
	Retry      int
	TaskData   *models.ZapTask
	Status     bool
}

func NewZapJob

func NewZapJob() *ZapJob

func (*ZapJob) Cancel

func (z *ZapJob) Cancel()

func (*ZapJob) Execute

func (z *ZapJob) Execute()

func (*ZapJob) ExecuteSuccess

func (z *ZapJob) ExecuteSuccess()

func (*ZapJob) Exit

func (z *ZapJob) Exit(status string, err error)

func (*ZapJob) Unlock

func (z *ZapJob) Unlock()

type ZapJobInterface

type ZapJobInterface interface {
	Execute()
}

Jump to

Keyboard shortcuts

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