2025-09-08 12:46:23 +00:00
|
|
|
import * as plugins from '../plugins.js';
|
|
|
|
|
feat: Implement Cloudly Task Manager with predefined tasks and execution tracking
- Added CloudlyTaskManager class for managing tasks, including registration, execution, scheduling, and cancellation.
- Created predefined tasks: DNS Sync, Certificate Renewal, Cleanup, Health Check, Resource Report, Database Maintenance, Security Scan, and Docker Cleanup.
- Introduced ITaskExecution interface for tracking task execution details and outcomes.
- Developed API request interfaces for task management operations (getTasks, getTaskExecutions, triggerTask, cancelTask).
- Implemented CloudlyViewTasks web component for displaying tasks and their execution history, including filtering and detailed views.
2025-09-10 16:37:03 +00:00
|
|
|
@plugins.smartdata.managed()
|
2025-09-08 12:46:23 +00:00
|
|
|
export class Deployment extends plugins.smartdata.SmartDataDbDoc<
|
|
|
|
Deployment,
|
|
|
|
plugins.servezoneInterfaces.data.IDeployment
|
|
|
|
> {
|
|
|
|
@plugins.smartdata.unI()
|
|
|
|
public id: string = plugins.smartunique.uniSimple('deployment');
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public serviceId: string;
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public nodeId: string;
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public containerId?: string;
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public usedImageId: string;
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public version: string;
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public deployedAt: number;
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public deploymentLog: string[] = [];
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public status: 'scheduled' | 'starting' | 'running' | 'stopping' | 'stopped' | 'failed';
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public healthStatus?: 'healthy' | 'unhealthy' | 'unknown';
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
public resourceUsage?: {
|
|
|
|
cpuUsagePercent: number;
|
|
|
|
memoryUsedMB: number;
|
|
|
|
lastUpdated: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
public static async createDeployment(
|
|
|
|
deploymentData: Partial<plugins.servezoneInterfaces.data.IDeployment>
|
|
|
|
): Promise<Deployment> {
|
|
|
|
const deployment = new Deployment();
|
|
|
|
if (deploymentData.serviceId) deployment.serviceId = deploymentData.serviceId;
|
|
|
|
if (deploymentData.nodeId) deployment.nodeId = deploymentData.nodeId;
|
|
|
|
if (deploymentData.containerId) deployment.containerId = deploymentData.containerId;
|
|
|
|
if (deploymentData.usedImageId) deployment.usedImageId = deploymentData.usedImageId;
|
|
|
|
if (deploymentData.version) deployment.version = deploymentData.version;
|
|
|
|
if (deploymentData.deployedAt) deployment.deployedAt = deploymentData.deployedAt;
|
|
|
|
if (deploymentData.deploymentLog) deployment.deploymentLog = deploymentData.deploymentLog;
|
|
|
|
if (deploymentData.status) deployment.status = deploymentData.status;
|
|
|
|
if (deploymentData.healthStatus) deployment.healthStatus = deploymentData.healthStatus;
|
|
|
|
if (deploymentData.resourceUsage) deployment.resourceUsage = deploymentData.resourceUsage;
|
|
|
|
|
|
|
|
await deployment.save();
|
|
|
|
return deployment;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async updateHealthStatus(healthStatus: 'healthy' | 'unhealthy' | 'unknown') {
|
|
|
|
this.healthStatus = healthStatus;
|
|
|
|
await this.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async updateResourceUsage(cpuUsagePercent: number, memoryUsedMB: number) {
|
|
|
|
this.resourceUsage = {
|
|
|
|
cpuUsagePercent,
|
|
|
|
memoryUsedMB,
|
|
|
|
lastUpdated: Date.now(),
|
|
|
|
};
|
|
|
|
await this.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async addLogEntry(entry: string) {
|
|
|
|
this.deploymentLog.push(entry);
|
|
|
|
await this.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async createSavableObject(): Promise<plugins.servezoneInterfaces.data.IDeployment> {
|
|
|
|
return {
|
|
|
|
id: this.id,
|
|
|
|
serviceId: this.serviceId,
|
|
|
|
nodeId: this.nodeId,
|
|
|
|
containerId: this.containerId,
|
|
|
|
usedImageId: this.usedImageId,
|
|
|
|
version: this.version,
|
|
|
|
deployedAt: this.deployedAt,
|
|
|
|
deploymentLog: this.deploymentLog,
|
|
|
|
status: this.status,
|
|
|
|
healthStatus: this.healthStatus,
|
|
|
|
resourceUsage: this.resourceUsage,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|