prepare service management
This commit is contained in:
@ -3,7 +3,7 @@ import * as paths from '../paths.js';
|
||||
import { Cloudly } from '../classes.cloudly.js';
|
||||
import { logger } from '../logger.js';
|
||||
|
||||
import { Cluster } from './cluster.js';
|
||||
import { Cluster } from './classes.cluster.js';
|
||||
|
||||
export class ClusterManager {
|
||||
public ready = plugins.smartpromise.defer();
|
||||
@ -28,7 +28,6 @@ export class ClusterManager {
|
||||
name: dataArg.clusterName,
|
||||
jumpCode: plugins.smartunique.uniSimple('cluster'),
|
||||
jumpCodeUsedAt: null,
|
||||
secretKey: plugins.smartunique.shortId(16),
|
||||
acmeInfo: null,
|
||||
cloudlyUrl: `https://${this.cloudlyRef.config.data.publicUrl}:${this.cloudlyRef.config.data.publicPort}/`,
|
||||
servers: [],
|
||||
@ -54,6 +53,17 @@ export class ClusterManager {
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
// delete cluster
|
||||
this.typedrouter.addTypedHandler<plugins.servezoneInterfaces.requests.cluster.IRequest_DeleteCluster>(
|
||||
new plugins.typedrequest.TypedHandler('deleteCluster', async (reqDataArg, toolsArg) => {
|
||||
await toolsArg.passGuards([this.cloudlyRef.authManager.adminJwtGuard], reqDataArg);
|
||||
await this.deleteCluster(reqDataArg.clusterId);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public async init() {
|
||||
@ -86,9 +96,9 @@ export class ClusterManager {
|
||||
await this.ready.promise;
|
||||
|
||||
return await Cluster.getInstance({
|
||||
id: clusterIdentifier.clusterId,
|
||||
data: {
|
||||
name: clusterIdentifier.clusterName,
|
||||
secretKey: clusterIdentifier.secretKey,
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -128,4 +138,10 @@ export class ClusterManager {
|
||||
await clusterInstance.save();
|
||||
return clusterInstance;
|
||||
}
|
||||
|
||||
public async deleteCluster(clusterId: string) {
|
||||
await this.ready.promise;
|
||||
const clusterInstance = await Cluster.getInstance({ id: clusterId });
|
||||
await clusterInstance.delete();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user