Server IP : 85.214.239.14 / Your IP : 3.147.69.91 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/3/cwd/proc/3/root/proc/2/cwd/lib/node_modules/pm2/lib/API/Modules/ |
Upload File : |
var path = require('path'); var fs = require('fs'); var os = require('os'); var spawn = require('child_process').spawn; var chalk = require('chalk'); var parallel = require('async/parallel'); var Configuration = require('../../Configuration.js'); var cst = require('../../../constants.js'); var Common = require('../../Common'); var Utility = require('../../Utility.js'); var readline = require('readline') var INTERNAL_MODULES = { 'deep-monitoring': { dependencies: [{name: 'v8-profiler-node8'}, {name: 'gc-stats'}, {name: 'event-loop-inspector'}] }, 'gc-stats': {name: 'gc-stats'}, 'event-loop-inspector': {name: 'event-loop-inspector'}, 'v8-profiler': {name: 'v8-profiler-node8'}, 'profiler': {name: 'v8-profiler-node8'}, 'typescript': {dependencies: [{name: 'typescript'}, {name: 'ts-node@latest'}]}, 'livescript': {name: 'livescript'}, 'coffee-script': {name: 'coffee-script', message: 'Coffeescript v1 support'}, 'coffeescript': {name: 'coffeescript', message: 'Coffeescript v2 support'} }; module.exports = { install, INTERNAL_MODULES, installMultipleModules } function install(module, cb, verbose) { if (!module || !module.name || module.name.length === 0) { return cb(new Error('No module name !')); } if (typeof verbose === 'undefined') { verbose = true; } installLangModule(module.name, function (err) { var display = module.message || module.name; if (err) { if (verbose) { Common.printError(cst.PREFIX_MSG_MOD_ERR + chalk.bold.green(display + ' installation has FAILED (checkout previous logs)')); } return cb(err); } if (verbose) { Common.printOut(cst.PREFIX_MSG + chalk.bold.green(display + ' ENABLED')); } return cb(); }); } function installMultipleModules(modules, cb, post_install) { var functionList = []; for (var i = 0; i < modules.length; i++) { functionList.push((function (index) { return function (callback) { var module = modules[index]; if (typeof modules[index] === 'string') { module = {name: modules[index]}; } install(module, function ($post_install, err, $index, $modules) { try { var install_instance = spawn(post_install[modules[index]], { stdio : 'inherit', windowsHide: true, env: process.env, shell : true, cwd : process.cwd() }); Common.printOut(cst.PREFIX_MSG_MOD + 'Running configuraton script.'); } catch(e) { Common.printOut(cst.PREFIX_MSG_MOD + 'No configuraton script found.'); } callback(null, { module: module, err: err }); }, false); }; })(i)); } parallel(functionList, function (err, results) { for (var i = 0; i < results.length; i++) { var display = results[i].module.message || results[i].module.name; if (results[i].err) { err = results[i].err; Common.printError(cst.PREFIX_MSG_MOD_ERR + chalk.bold.green(display + ' installation has FAILED (checkout previous logs)')); } else { Common.printOut(cst.PREFIX_MSG + chalk.bold.green(display + ' ENABLED')); } } if(cb) cb(err); }); }; function installLangModule(module_name, cb) { var node_module_path = path.resolve(path.join(__dirname, '../../../')); Common.printOut(cst.PREFIX_MSG_MOD + 'Calling ' + chalk.bold.red('[NPM]') + ' to install ' + module_name + ' ...'); var install_instance = spawn(cst.IS_WINDOWS ? 'npm.cmd' : 'npm', ['install', module_name, '--loglevel=error'], { stdio : 'inherit', env: process.env, shell : true, cwd : node_module_path }); install_instance.on('close', function(code) { if (code > 0) return cb(new Error('Module install failed')); return cb(null); }); install_instance.on('error', function (err) { console.error(err.stack || err); }); };