Socket
Socket
Sign inDemoInstall

pm2

Package Overview
Dependencies
29
Maintainers
1
Versions
277
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.9.2-next to 2.9.2

21

CHANGELOG.md
## 2.9.2
- #3364 30% faster CLI via v8-compile-cache
- add process._getActiveRequests() and process._getActiveHandles() custom metrics
- #3402 #3360 fix bad username
- #3413 check dependencies before launching tests
- #3295 add sorting feature for process list (pm2 ls --sort <field_name:order>)
- #3404 if no gid specified - set gid to uid
- #3287 add typing for env
- #3374 separate stdout and stderr for pm2-docker/pm2-runtime
- #3366 improve building of rpm and deb packages
- #3375 sendLineToStdin/sendDataToProcessId fix
- #3365 fix report command for windows
- #3367 Display an error if the process is not found when running 'pm2 logs <process-name>'
- #3256 TypeError: Cannot read property 'destroy' of undefined
- User: append SUDO_USER if no uid has been set and SUDO_USER present
- User: check permission of agent
- KM: send outliers
- KM: infinite retry for km connection
## 2.9.1

@@ -3,0 +24,0 @@

6

lib/API.js

@@ -692,2 +692,5 @@ /**

app_conf = appConf[0];
app_conf.username = Common.getCurrentUsername();
/**

@@ -941,2 +944,3 @@ * If -w option, write configuration to configuration.json file

app.name += ('-' + opts.env);
app.username = Common.getCurrentUsername();
apps_name.push(app.name);

@@ -1538,3 +1542,3 @@ });

}
UX.dispAsTable(list, that.gl_interact_infos);
UX.dispAsTable(list, commander);
Common.printOut(chalk.white.italic(' Use `pm2 show <id|name>` to get more details about an app'));

@@ -1541,0 +1545,0 @@ }

75

lib/API/CliUx.js

@@ -196,6 +196,6 @@ /**

* @param {} list
* @param {} interact_infos
* @param {} commander
* @return
*/
UX.dispAsTable = function(list, interact_infos) {
UX.dispAsTable = function(list, commander) {
var stacked = (process.stdout.columns || 90) < 90;

@@ -222,19 +222,39 @@ var app_head = stacked ? ['Name', 'mode', 'status', '↺', 'cpu', 'memory'] :

var current_user = '';
var sortField = 'name', sortOrder = 'asc', sort,
fields = {
name: 'pm2_env.name',
pid: 'pid',
id: 'pm_id',
cpu: 'monit.cpu',
memory: 'monit.memory',
uptime: 'pm2_env.pm_uptime',
status: 'pm2_env.status'
};
if (os.userInfo)
try {
current_user = os.userInfo().username;
} catch (err) {
// For the case of unhandled error for uv_os_get_passwd
// https://github.com/Unitech/pm2/issues/3184
current_user = '';
} else {
current_user = process.env.USER || process.env.LNAME || process.env.USERNAME || process.env.SUDO_USER || process.env.C9_USER || process.env.LOGNAME;
if(commander && commander.sort) {
sort = commander.sort.split(':');
if(fields[sort[0].toLowerCase()]) {
sortField = sort[0].toLowerCase();
sortOrder = sort.length === 2 ? sort[1] : 'asc';
}
}
list.sort(function(a, b) {
if (a.pm2_env.name < b.pm2_env.name)
return -1;
if (a.pm2_env.name > b.pm2_env.name)
return 1;
var fieldA = getNestedProperty(fields[sortField], a);
var fieldB = getNestedProperty(fields[sortField], b);
if(sortOrder === 'desc') {
if (fieldA > fieldB)
return -1;
if (fieldA < fieldB)
return 1;
} else {
if (fieldA < fieldB)
return -1;
if (fieldA > fieldB)
return 1;
}
return 0;

@@ -282,3 +302,3 @@ });

if (!stacked)
obj[key].push(chalk.bold(l.pm2_env.uid || current_user));
obj[key].push(chalk.bold(l.pm2_env.uid || l.pm2_env.username));

@@ -320,3 +340,3 @@ safe_push(module_table, obj);

if (!stacked)
obj[key].push(chalk.bold(l.pm2_env.uid || current_user));
obj[key].push(chalk.bold(l.pm2_env.uid || l.pm2_env.username));

@@ -500,1 +520,20 @@ // Watch status

}
/**
* Get nested property
*
* @param {String} propertyName
* @param {Object} obj
* @returns {String} property value
*/
function getNestedProperty(propertyName, obj) {
var parts = propertyName.split('.'),
length = parts.length,
property = obj || {};
for ( i = 0; i < length; i++ ) {
property = property[parts[i]];
}
return property;
}

@@ -69,5 +69,7 @@

fmt.field('argv0', process.argv0);
fmt.field('user', process.env.USER);
fmt.field('uid', process.geteuid());
fmt.field('gid', process.getegid());
fmt.field('user', process.env.USER || process.env.LNAME || process.env.USERNAME);
if (process.geteuid)
fmt.field('uid', process.geteuid());
if (process.getegid)
fmt.field('gid', process.getegid());

@@ -74,0 +76,0 @@ var os = require('os');

@@ -120,3 +120,3 @@ /**

if (raw)
return process.stdout.write(util.format(line) + '\n');
return type === 'err' ? process.stderr.write(util.format(line) + '\n') : process.stdout.write(util.format(line) + '\n');

@@ -281,5 +281,2 @@ if (timestamp)

function printLines(lines) {
}
function pad(pad, str, padLeft) {

@@ -286,0 +283,0 @@ if (typeof str === 'undefined')

@@ -190,2 +190,7 @@ var chalk = require('chalk');

if (files_list && files_list.length == 0) {
Common.printError(cst.PREFIX_MSG_ERR + 'No file to stream for app [%s], exiting.', id);
return process.exit(cst.ERROR_EXIT);
}
if (!raw && (id === 'all' || id === 'PM2') && exclusive === false) {

@@ -192,0 +197,0 @@ Log.tail([{

@@ -13,2 +13,3 @@ /**

var path = require('path');
var os = require('os');
var util = require('util');

@@ -633,2 +634,27 @@ var mkdirp = require('mkdirp');

/**
* Get current username
* Called on EVERY starting app
*
* @returns {String}
*/
Common.getCurrentUsername = function(){
var current_user = '';
if (os.userInfo) {
try {
current_user = os.userInfo().username;
} catch (err) {
// For the case of unhandled error for uv_os_get_passwd
// https://github.com/Unitech/pm2/issues/3184
}
}
if(current_user === '') {
current_user = process.env.USER || process.env.LNAME || process.env.USERNAME || process.env.SUDO_USER || process.env.C9_USER || process.env.LOGNAME;
}
return current_user;
}
/**
* Check if right Node.js version for cluster mode

@@ -635,0 +661,0 @@ * @param {Object} conf

@@ -625,3 +625,3 @@ /**

God.sendLineToStdin = function(packet, cb) {
if (typeof(packet.pm_id) == undefined || !packet.line)
if (typeof(packet.pm_id) == 'undefined' || !packet.line)
return cb(God.logAndGenerateError('pm_id or line field missing'), {});

@@ -656,3 +656,3 @@

God.sendDataToProcessId = function(packet, cb) {
if (typeof(packet.id) == undefined ||
if (typeof(packet.id) == 'undefined' ||
!packet.data ||

@@ -659,0 +659,0 @@ !packet.topic)

@@ -252,7 +252,9 @@ /**

console.error('Got error while connecting: %s', err.message || err);
if (retries < 5) {
if (retries < 30) {
retries++;
setTimeout(function() {
doWelcomeQuery(cb);
}, 600);
}, 200 * retries);
return false;

@@ -271,13 +273,18 @@ }

// For Human feedback
if (process.send)
process.send({
error : false,
km_data : km_data,
online : true,
pid : process.pid,
machine_name : self.opts.MACHINE_NAME,
public_key : self.opts.PUBLIC_KEY,
secret_key : self.opts.SECRET_KEY,
reverse_interaction : self.opts.REVERSE_INTERACT
});
if (process.send) {
try {
process.send({
error : false,
km_data : km_data,
online : true,
pid : process.pid,
machine_name : self.opts.MACHINE_NAME,
public_key : self.opts.PUBLIC_KEY,
secret_key : self.opts.SECRET_KEY,
reverse_interaction : self.opts.REVERSE_INTERACT
});
} catch(e) {
// Just in case the CLI has been disconected
}
}
// Return get data

@@ -284,0 +291,0 @@ return cb(null, km_data);

@@ -248,3 +248,14 @@ /**

var t = setTimeout(function() {
UX.processing.stop();
Common.printOut(cst.PREFIX_MSG_WARNING + ' Not managed to connect to Keymetrics, retrying in background. (check %s)', cst.INTERACTOR_LOG_FILE_PATH);
child.removeAllListeners('message');
child.removeAllListeners('error');
child.disconnect();
return cb(null, {}, child);
}, 7000);
child.once('message', function(msg) {
clearTimeout(t);
debug('Interactor daemon launched', msg);

@@ -251,0 +262,0 @@

@@ -45,3 +45,3 @@ /**

reconnect : true,
retryInterval : 100,
retryInterval : 2000,
max : Infinity,

@@ -48,0 +48,0 @@ maxListeners : 50

@@ -343,9 +343,27 @@ /**

if (trace.spans[0].mean > variance.histogram.percentiles([0.95])[0.95] &&
typeof pushInteractor !== 'undefined' && process.initialization_timeout === null) {
typeof pushInteractor !== 'undefined' && !process.initialization_timeout) {
// serialize and add metadata
self.parseStacktrace(trace.spans)
var data = {
data: fclone(trace),
trace: fclone(trace.spans),
variance: fclone(variance.spans.map(function (span) {
return {
labels: span.labels,
kind: span.kind,
name: span.name,
startTime: span.startTime,
percentiles: {
p5: variance.histogram.percentiles([0.5])[0.5],
p95: variance.histogram.percentiles([0.95])[0.95]
}
}
})),
meta: {
value: trace.spans[0].mean,
percentiles: variance.histogram.percentiles([0.5, 0.75, 0.95, 0.99]),
percentiles: {
p5: variance.histogram.percentiles([0.5])[0.5],
p75: variance.histogram.percentiles([0.75])[0.75],
p95: variance.histogram.percentiles([0.95])[0.95],
p99: variance.histogram.percentiles([0.99])[0.99]
},
min: variance.histogram.getMin(),

@@ -352,0 +370,0 @@ max: variance.histogram.getMax(),

@@ -63,4 +63,6 @@ /**

if (process.env.uid){
process.initgroups(process.env.uid, process.env.uid);
process.setgid(process.env.uid);
// If no gid specified - set gid to uid
var new_gid = process.env.gid == null ? process.env.uid : process.env.gid;
process.initgroups(process.env.uid, new_gid);
process.setgid(new_gid);
process.setuid(process.env.uid);

@@ -67,0 +69,0 @@ }

{
"name": "pm2",
"preferGlobal": true,
"version": "2.9.2-next",
"version": "2.9.2",
"engines": {

@@ -28,2 +28,6 @@ "node": ">=0.12"

{
"name": "wallet77",
"email": "wallet77@gmail.com"
},
{
"name": "vmarchaud",

@@ -91,3 +95,3 @@ "email": "contact@vmarchaud.fr"

"scripts": {
"test": "NODE_ENV=test bash test/pm2_programmatic_tests.sh && NODE_ENV=test bash test/pm2_behavior_tests.sh",
"test": "NODE_ENV=test bash test/pm2_check_dependencies.sh && NODE_ENV=test bash test/pm2_programmatic_tests.sh && NODE_ENV=test bash test/pm2_behavior_tests.sh",
"bench-pmx": "pm2 delete all; pm2 install pm2-probe; node examples/pmx/app.js; pm2 ls"

@@ -178,3 +182,3 @@ },

"pm2-multimeter": "^0.1.2",
"pmx": "^1.5",
"pmx": "~1.5.*",
"semver": "^5.3",

@@ -181,0 +185,0 @@ "shelljs": "0.7.8",

@@ -8,3 +8,4 @@ <div align="center">

<br/>
<b>P</b>(rocess) <b>M</b>(anager) <b>2</b>
<b>P</b>(rocess) <b>M</b>(anager) <b>2</b><br/>
<i>Runtime Edition</i>
<br/><br/>

@@ -65,18 +66,15 @@

## Official Docker Image
## Container Support
Docker Hub PM2 image:
Using Containers? We got your back with pm2-runtime, a dedicated command for running Node.js in containers and our [officialy suported Docker image](https://hub.docker.com/r/keymetrics/pm2/).
[PM2 Official Docker Image](https://hub.docker.com/r/keymetrics/pm2/)
Using it:
Using the pm2-docker CLI:
```
FROM keymetrics/pm2:latest
FROM keymetrics/pm2:latest-alpine
[...]
CMD [ "pm2-docker", "start", "ecosystem.config.js" ]
CMD [ "pm2-runtime", "ecosystem.config.js" ]
```
More about Docker/PM2 integration:
[pm2 Docker support](http://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/)
[Read More about the dedicated integration](http://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/)

@@ -123,2 +121,3 @@ ## Monitor PM2 and Applications

$ pm2 list # List all processes started with PM2
$ pm2 list --sort=<field> # Sort all processes started with PM2
$ pm2 monit # Display memory and cpu usage of each app

@@ -125,0 +124,0 @@ $ pm2 show [app-name] # Show all information about application

@@ -390,2 +390,6 @@ // Type definitions for pm2 2.7.1

disableSourceMapSupport?: any;
/**
* The environment variables to pass on to the process.
*/
env?: { [key: string]: string; };
}

@@ -392,0 +396,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc