mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-30 16:27:21 +08:00
Return committed trigger IDs and add CLI wait and trigger-specific logs while preserving API, CLI, transaction, deduplication and unknown-result semantics. Move scheduling, lifecycle, settlement, queries and legacy adapters into back/cron; remove obsolete internal import paths and circular dependencies. Apply project formatting across the repository, cover CJS/MJS in formatting hooks, add prettier:check and require formatting checks in AGENTS.md. Validation: backend build; 1398 backend/frontend tests passed (17 platform skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
89 lines
1.9 KiB
TypeScript
89 lines
1.9 KiB
TypeScript
import { sequelize } from '.';
|
|
import { DataTypes, Model } from 'sequelize';
|
|
|
|
export enum InstanceStatus {
|
|
'running' = 0,
|
|
'finished' = 1,
|
|
'stopped' = 2,
|
|
'error' = 3,
|
|
'unknown' = 4,
|
|
}
|
|
|
|
export interface RunningInstanceAttributes {
|
|
id?: number;
|
|
cron_id: number;
|
|
pid?: number;
|
|
log_path?: string;
|
|
started_at: number;
|
|
finished_at?: number;
|
|
status: InstanceStatus;
|
|
exit_code?: number;
|
|
}
|
|
|
|
export class RunningInstance {
|
|
id?: number;
|
|
cron_id!: number;
|
|
pid?: number;
|
|
log_path?: string;
|
|
started_at!: number;
|
|
finished_at?: number;
|
|
status!: InstanceStatus;
|
|
exit_code?: number;
|
|
|
|
constructor(options: RunningInstanceAttributes) {
|
|
this.id = options.id;
|
|
this.cron_id = options.cron_id;
|
|
this.pid = options.pid;
|
|
this.log_path = options.log_path;
|
|
this.started_at = options.started_at;
|
|
this.finished_at = options.finished_at;
|
|
this.status = options.status;
|
|
this.exit_code = options.exit_code;
|
|
}
|
|
}
|
|
|
|
export interface RunningInstanceModel
|
|
extends Model<RunningInstanceAttributes, RunningInstanceAttributes>,
|
|
RunningInstanceAttributes {}
|
|
|
|
export const RunningInstanceModel = sequelize.define<RunningInstanceModel>(
|
|
'RunningInstance',
|
|
{
|
|
cron_id: {
|
|
type: DataTypes.NUMBER,
|
|
allowNull: false,
|
|
},
|
|
pid: {
|
|
type: DataTypes.NUMBER,
|
|
allowNull: true,
|
|
},
|
|
log_path: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true,
|
|
},
|
|
started_at: {
|
|
type: DataTypes.NUMBER,
|
|
allowNull: false,
|
|
},
|
|
finished_at: {
|
|
type: DataTypes.NUMBER,
|
|
allowNull: true,
|
|
},
|
|
status: {
|
|
type: DataTypes.NUMBER,
|
|
allowNull: false,
|
|
defaultValue: InstanceStatus.running,
|
|
},
|
|
exit_code: {
|
|
type: DataTypes.NUMBER,
|
|
allowNull: true,
|
|
},
|
|
},
|
|
{
|
|
indexes: [
|
|
{ fields: ['cron_id', 'pid', 'started_at'] },
|
|
{ fields: ['cron_id', 'id'] },
|
|
],
|
|
},
|
|
);
|