pandora
Version:
A powerful and lightweight application manager for Node.js applications powered by TypeScript.
63 lines • 2.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ProcessRepresentationChainModifier_1 = require("./ProcessRepresentationChainModifier");
/**
* Class ProcfileReconcilerAccessor
* A easy way to access ProcfileReconciler
*/
class ProcfileReconcilerAccessor {
constructor(procfileReconciler) {
this.procfileReconciler = null;
this.clusterCount = 0;
this.procfileReconciler = procfileReconciler;
}
get dev() {
return process.env.PANDORA_DEV === 'true';
}
get appName() {
return this.procfileReconciler.appRepresentation.appName;
}
get appDir() {
return this.procfileReconciler.appRepresentation.appDir;
}
/**
* define process
* @param processName
* @return {ProcessRepresentationChainModifier}
*/
process(processName) {
const savedRepresentation = this.procfileReconciler.getProcessByName(processName);
if (savedRepresentation) {
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(savedRepresentation, this.procfileReconciler);
}
const representation = this.procfileReconciler.defineProcess({
processName
});
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(representation, this.procfileReconciler);
}
/**
* Define fork a process
* @param processName
* @param entryFile
* @return {ProcessRepresentationChainModifier}
*/
fork(processName, entryFile) {
const representation = this.procfileReconciler.defineProcess({
entryFile,
processName
});
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(representation, this.procfileReconciler);
}
cluster(a, b) {
const entryFile = (arguments.length === 1) ? a : b;
const processName = (arguments.length === 1) ? 'cluster' + this.clusterCount++ : a;
const representation = this.procfileReconciler.defineProcess({
entryFile,
processName,
scale: 'auto'
});
return new ProcessRepresentationChainModifier_1.ProcessRepresentationChainModifier(representation, this.procfileReconciler);
}
}
exports.ProcfileReconcilerAccessor = ProcfileReconcilerAccessor;
//# sourceMappingURL=ProcfileReconcilerAccessor.js.map