2022-01-30 12:22:18 +01:00
|
|
|
package lib
|
|
|
|
|
2023-08-29 00:51:04 +02:00
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"time"
|
|
|
|
)
|
2022-01-30 12:22:18 +01:00
|
|
|
|
2023-09-23 17:12:35 +02:00
|
|
|
type TaskStatus string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TaskWaitingStatus TaskStatus = "waiting"
|
|
|
|
TaskStartingStatus TaskStatus = "starting"
|
|
|
|
TaskRunningStatus TaskStatus = "running"
|
|
|
|
TaskStoppingStatus TaskStatus = "stopping"
|
|
|
|
TaskStoppedStatus TaskStatus = "stopped"
|
|
|
|
TaskSuccessStatus TaskStatus = "success"
|
|
|
|
TaskFailStatus TaskStatus = "error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s TaskStatus) IsFinished() bool {
|
|
|
|
return s == TaskStoppedStatus || s == TaskSuccessStatus || s == TaskFailStatus
|
|
|
|
}
|
|
|
|
|
2022-01-30 12:22:18 +01:00
|
|
|
type Logger interface {
|
|
|
|
Log(msg string)
|
2023-08-29 00:51:04 +02:00
|
|
|
Log2(msg string, now time.Time)
|
2022-01-30 12:22:18 +01:00
|
|
|
LogCmd(cmd *exec.Cmd)
|
2023-09-23 17:12:35 +02:00
|
|
|
SetStatus(status TaskStatus)
|
2022-01-30 12:22:18 +01:00
|
|
|
}
|