qinglong/back/data/cron.ts
2021-10-28 22:38:34 +08:00

41 lines
950 B
TypeScript

export class Crontab {
name?: string;
command: string;
schedule: string;
timestamp?: string;
created?: number;
saved?: boolean;
_id?: string;
status?: CrontabStatus;
isSystem?: 1 | 0;
pid?: number;
isDisabled?: 1 | 0;
log_path?: string;
isPinned?: 1 | 0;
constructor(options: Crontab) {
this.name = options.name;
this.command = options.command;
this.schedule = options.schedule;
this.saved = options.saved;
this._id = options._id;
this.created = options.created;
this.status = CrontabStatus[options.status]
? options.status
: CrontabStatus.idle;
this.timestamp = new Date().toString();
this.isSystem = options.isSystem || 0;
this.pid = options.pid;
this.isDisabled = options.isDisabled || 0;
this.log_path = options.log_path || '';
this.isPinned = options.isPinned || 0;
}
}
export enum CrontabStatus {
'running',
'idle',
'disabled',
'queued',
}