Server IP : 85.214.239.14 / Your IP : 18.191.104.49 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/3/cwd/proc/3/cwd/proc/3/root/proc/2/cwd/usr/lib/node_modules/pm2/lib/API/pm2-plus/ |
Upload File : |
var cst = require('../../../constants.js'); var Common = require('../../Common.js'); var chalk = require('chalk'); var fs = require('fs'); var KMDaemon = require('@pm2/agent/src/InteractorClient'); var pkg = require('../../../package.json') module.exports = function(CLI) { CLI.prototype.linkManagement = function(cmd, public_key, machine, opts, cb) { var that = this; // pm2 link stop || kill if (cmd == 'stop' || cmd == 'kill') { that.gl_is_km_linked = false console.log(cst.PM2_IO_MSG + ' Stopping agent...'); return that.killAgent(function(err) { if (err) { Common.printError(err); return process.exit(cst.ERROR_EXIT); } console.log(cst.PM2_IO_MSG + ' Stopped'); that.reload('all', () => { return process.exit(cst.SUCCESS_EXIT); }) }); } // pm2 link info if (cmd == 'info') { console.log(cst.PM2_IO_MSG + ' Getting agent information...'); that.agentInfos(function(err, infos) { if (err) { console.error(cst.PM2_IO_MSG_ERR + ' ' + err.message); return that.exitCli(cst.ERROR_EXIT); } console.log(infos); return that.exitCli(cst.SUCCESS_EXIT); }); return false; } // pm2 link delete if (cmd == 'delete') { that.gl_is_km_linked = false console.log(cst.PM2_IO_MSG + ' Permanently disable agent...'); that.killAgent(function(err) { try { fs.unlinkSync(cst.INTERACTION_CONF); } catch(e) { console.log(cst.PM2_IO_MSG + ' No interaction config file found'); return process.exit(cst.SUCCESS_EXIT); } console.log(cst.PM2_IO_MSG + ' Agent interaction ended'); if (!cb) return process.exit(cst.SUCCESS_EXIT); return cb() }); return false; } if (cmd && !public_key) { console.error(cst.PM2_IO_MSG + ' Command [%s] unknown or missing public key', cmd); return process.exit(cst.ERROR_EXIT); } // pm2 link xxx yyy var infos; if (!cmd) { infos = null; } else infos = { public_key : public_key, secret_key : cmd, machine_name : machine, info_node : opts.infoNode || null, pm2_version: pkg.version } that.link(infos, cb) }; CLI.prototype.link = function(infos, cb) { var that = this; process.env.WS_JSON_PATCH = true KMDaemon.launchAndInteract(cst, infos, function(err, dt) { if (err) { Common.printError(cst.PM2_IO_MSG + ' Run `$ pm2 plus` to connect') return that.exitCli(cst.ERROR_EXIT); } console.log(chalk.bold.green('[+] PM2+ activated!')) if (!cb) { return that.exitCli(cst.SUCCESS_EXIT); } return cb(null, dt) }); }; CLI.prototype.agentInfos = function(cb) { KMDaemon.getInteractInfo(this._conf, function(err, data) { if (err) return cb(Common.retErr(err)); return cb(null, data); }); }; CLI.prototype.killAgent = function(cb) { var that = this; KMDaemon.killInteractorDaemon(that._conf, function(err) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.SUCCESS_EXIT); return cb ? cb(null) : that.exitCli(cst.SUCCESS_EXIT); }); }; CLI.prototype.unlink = function(cb) { this.linkManagement('delete', cb); }; };