- 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.
		
			
				
	
	
		
			158 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			158 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import * as plugins from './plugins.js';
 | |
| import { CloudlyConfig } from './classes.config.js';
 | |
| 
 | |
| // interfaces
 | |
| import {} from '@tsclass/tsclass';
 | |
| 
 | |
| // Cloudly mods
 | |
| import { CloudlyInfo } from './classes.cloudlyinfo.js';
 | |
| import { CloudlyServer } from './classes.server.js';
 | |
| 
 | |
| // connectors
 | |
| import { CloudflareConnector } from './connector.cloudflare/connector.js';
 | |
| import { LetsencryptConnector } from './connector.letsencrypt/connector.js';
 | |
| import { MongodbConnector } from './connector.mongodb/connector.js';
 | |
| 
 | |
| // processes
 | |
| import { CloudlyCoreflowManager } from './manager.coreflow/coreflowmanager.js';
 | |
| import { ClusterManager } from './manager.cluster/classes.clustermanager.js';
 | |
| import { CloudlyTaskManager } from './manager.task/classes.taskmanager.js';
 | |
| import { CloudlySecretManager } from './manager.secret/classes.secretmanager.js';
 | |
| import { CloudlyNodeManager } from './manager.node/classes.nodemanager.js';
 | |
| import { CloudlyBaremetalManager } from './manager.baremetal/classes.baremetalmanager.js';
 | |
| import { ExternalApiManager } from './manager.status/statusmanager.js';
 | |
| import { ExternalRegistryManager } from './manager.externalregistry/index.js';
 | |
| import { ImageManager } from './manager.image/classes.imagemanager.js';
 | |
| import { ServiceManager } from './manager.service/classes.servicemanager.js';
 | |
| import { DeploymentManager } from './manager.deployment/classes.deploymentmanager.js';
 | |
| import { DnsManager } from './manager.dns/classes.dnsmanager.js';
 | |
| import { DomainManager } from './manager.domain/classes.domainmanager.js';
 | |
| import { logger } from './logger.js';
 | |
| import { CloudlyAuthManager } from './manager.auth/classes.authmanager.js';
 | |
| import { CloudlySettingsManager } from './manager.settings/classes.settingsmanager.js';
 | |
| 
 | |
| /**
 | |
|  * Cloudly class can be used to instantiate a cloudly server.
 | |
|  * It is implemented as class in order to make it easier ro write node services that are more adjusted to invidual services
 | |
|  *
 | |
|  * ```ts
 | |
|  * const mycloudly = new Cloudly ({...})
 | |
|  * ```
 | |
|  */
 | |
| export class Cloudly {
 | |
|   public typedrouter = new plugins.typedrequest.TypedRouter();
 | |
| 
 | |
|   public config: CloudlyConfig;
 | |
|   public logger: plugins.smartlog.Smartlog;
 | |
|   public ready: Promise<any>;
 | |
| 
 | |
|   // mods
 | |
|   public cloudlyInfo: CloudlyInfo;
 | |
|   public server: CloudlyServer;
 | |
| 
 | |
|   // connectors
 | |
|   public cloudflareConnector: CloudflareConnector;
 | |
|   public letsencryptConnector: LetsencryptConnector;
 | |
|   public mongodbConnector: MongodbConnector;
 | |
| 
 | |
|   // managers
 | |
|   public authManager: CloudlyAuthManager;
 | |
|   public secretManager: CloudlySecretManager;
 | |
|   public settingsManager: CloudlySettingsManager;
 | |
|   public clusterManager: ClusterManager;
 | |
|   public coreflowManager: CloudlyCoreflowManager;
 | |
|   public externalApiManager: ExternalApiManager;
 | |
|   public externalRegistryManager: ExternalRegistryManager;
 | |
|   public imageManager: ImageManager;
 | |
|   public serviceManager: ServiceManager;
 | |
|   public deploymentManager: DeploymentManager;
 | |
|   public dnsManager: DnsManager;
 | |
|   public domainManager: DomainManager;
 | |
|   public taskManager: CloudlyTaskManager;
 | |
|   public nodeManager: CloudlyNodeManager;
 | |
|   public baremetalManager: CloudlyBaremetalManager;
 | |
| 
 | |
|   private readyDeferred = new plugins.smartpromise.Deferred();
 | |
| 
 | |
|   private configOptions: plugins.servezoneInterfaces.data.ICloudlyConfig;
 | |
|   constructor(configArg?: plugins.servezoneInterfaces.data.ICloudlyConfig) {
 | |
|     this.configOptions = configArg;
 | |
|     this.cloudlyInfo = new CloudlyInfo(this);
 | |
|     this.config = new CloudlyConfig(this);
 | |
| 
 | |
|     this.logger = logger;
 | |
|     this.server = new CloudlyServer(this);
 | |
|     this.ready = this.readyDeferred.promise;
 | |
| 
 | |
|     // connectors
 | |
|     this.mongodbConnector = new MongodbConnector(this); // database needs to go first
 | |
|     this.cloudflareConnector = new CloudflareConnector(this);
 | |
|     this.letsencryptConnector = new LetsencryptConnector(this);
 | |
| 
 | |
|     // managers
 | |
|     this.authManager = new CloudlyAuthManager(this);
 | |
|     this.settingsManager = new CloudlySettingsManager(this);
 | |
|     this.clusterManager = new ClusterManager(this);
 | |
|     this.coreflowManager = new CloudlyCoreflowManager(this);
 | |
|     this.externalApiManager = new ExternalApiManager(this);
 | |
|     this.externalRegistryManager = new ExternalRegistryManager(this);
 | |
|     this.imageManager = new ImageManager(this);
 | |
|     this.serviceManager = new ServiceManager(this);
 | |
|     this.deploymentManager = new DeploymentManager(this);
 | |
|     this.dnsManager = new DnsManager(this);
 | |
|     this.domainManager = new DomainManager(this);
 | |
|     this.taskManager = new CloudlyTaskManager(this);
 | |
|     this.secretManager = new CloudlySecretManager(this);
 | |
|     this.nodeManager = new CloudlyNodeManager(this);
 | |
|     this.baremetalManager = new CloudlyBaremetalManager(this);
 | |
|   }
 | |
| 
 | |
|   /**
 | |
|    * starts the cloudly instance and
 | |
|    * @param configArg
 | |
|    */
 | |
|   public async start() {
 | |
|     // config
 | |
|     await this.config.init(this.configOptions);
 | |
| 
 | |
|     // database (data comes from config)
 | |
|     await this.mongodbConnector.init();
 | |
| 
 | |
|     // settings (are stored in db)
 | |
|     await this.settingsManager.init();
 | |
| 
 | |
|     // manageers
 | |
|     await this.authManager.start();
 | |
|     await this.secretManager.start();
 | |
|     await this.nodeManager.start();
 | |
|     await this.baremetalManager.start();
 | |
|     await this.serviceManager.start();
 | |
|     await this.deploymentManager.start();
 | |
|     await this.taskManager.init();
 | |
|     
 | |
|     await this.cloudflareConnector.init();
 | |
|     await this.letsencryptConnector.init();
 | |
|     await this.clusterManager.init();
 | |
|     await this.server.start();
 | |
|     this.readyDeferred.resolve();
 | |
| 
 | |
|     // start the managers
 | |
|     this.imageManager.start();
 | |
|     this.externalRegistryManager.start();
 | |
|   }
 | |
| 
 | |
|   /**
 | |
|    * stop the reception instance
 | |
|    */
 | |
|   public async stop() {
 | |
|     await this.server.stop();
 | |
|     await this.letsencryptConnector.stop();
 | |
|     await this.mongodbConnector.stop();
 | |
|     await this.secretManager.stop();
 | |
|     await this.serviceManager.stop();
 | |
|     await this.deploymentManager.stop();
 | |
|     await this.taskManager.stop();
 | |
|     await this.externalRegistryManager.stop();
 | |
|   }
 | |
| }
 |