| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/nami/node_modules/provisioner/lib/ |
Upload File : |
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const nami_wrapper_1 = require("./nami_wrapper");
const bitnami_module_1 = require("./bitnami_module");
const arguments_handler_1 = require("./arguments_handler");
/**
* Class for performing basic actions on a nami-based module
*/
class NamiModule extends bitnami_module_1.BitnamiModule {
/**
* Create instance of nami-based module handler
* @param tierDefinition definition of current tier (part of multi-VM deployment)
* @param moduleDefinition definition of this specific module
*/
constructor(tierDefinition, moduleDefinition) {
super(tierDefinition, moduleDefinition);
this.tierDefinition = tierDefinition;
this.moduleDefinition = moduleDefinition;
this._argumentHandler = new arguments_handler_1.ArgumentHandler(moduleDefinition.initializeArguments || [], this.provisioner, this.logger);
}
/**
* Whether an object is a service and should be started/stopped when all services should be
* stopped and started accordingly
*/
get isService() {
return this.namiRegistryModule.isService();
}
get namiRegistryModule() {
return this.provisioner.namiRegistry.find(this.name);
}
_runNamiCommand(args) {
const namiCommand = this.provisioner.platform.pathInfo.namiCommand;
args = args.splice(0);
args.unshift("--log-level", this.logger.logLevelName);
this.logger.verbose("Running nami command with", args.join(" "));
const result = nami_wrapper_1.os.runProgram(namiCommand, args, {
retrieveStdStreams: true
});
process.stdout.write(result.stdout);
process.stderr.write(result.stderr);
if (result.code !== 0) {
let message = `nami command failed with exit code ${result.code}:\n` +
`[nami stdout]\n${result.stdout}\n` +
`[nami stderr]\n${result.stderr}\n`;
throw new Error(message);
}
}
/**
* Install a module from directory where it was previously downloaded
* (by provisioner or other tool)
* @param directory Directory where module was downloaded to, NOT the subdirectory with module
*/
installModuleFromDirectory(directory) {
const args = ["unpack", `${directory}/${this.baseName}`];
this._runNamiCommand(args);
}
get initializationArguments() {
if (!this._initializationArguments) {
let args = this._argumentHandler.arguments;
args.unshift("initialize", this.name);
this._initializationArguments = args;
}
return this._initializationArguments;
}
/**
* Initialize a module ; arguments to pass to module are taken from its definition
*/
initializeModule() {
this._runNamiCommand(this.initializationArguments);
}
/**
* Start or stop a module
*/
serviceCommand(cmd) {
this._runNamiCommand([cmd, this.name]);
}
/**
* Call `nami execute <moduleName>` command with any additional arguments
*/
namiExecute(args) {
args = ["execute", this.moduleDefinition.name].concat(args);
this._runNamiCommand(args);
}
/**
* Execute an exported function
*/
runExport(cmd, args) {
const namiArgs = [cmd].concat(args || []);
this.namiExecute(namiArgs);
}
/**
* Check if a module exports a certain function
*/
exportsFunction(cmd) {
return this.namiRegistryModule.exportsFunction(cmd);
}
}
exports.NamiModule = NamiModule;