PM2 0.10 release
by Alexandre Strzelewicz -

We did it! After many contributions, bug reports and intensive internal usage, PM2 has been upgraded to the 0.10!

Process Manager 2, but what's new ?

Automatic restart on memory limit

Automatic restart based on reached memory limit. Excuse my French but it simply means that your app will be automatically restarted at a certain amount of memory.

$ pm2 start app.js --max-memory-restart=100

This command will restart the app.js if it reaches more than 100mb.

PM2 heart code refactored

The heart code of PM2 has been refactored and therefore hardened. Now it doesn't leak and it doesn't crash under any circumstances.

We benchmarked this by using servers as laboratories and we acted as crazy scientists making experiments.

Lightest memory footprint

Applications started with PM2 are now lighter in terms of memory than ever before, with results close to apps started directly with node.

The pm2 = require('pm2') is nice

The programmatic interface has been upgraded and now operates well. Write this to start the MY-APP-1.js script:

var pm2 = require('pm2');

pm2.connect(function(err) {

  // Start a script on the current folder
  pm2.start('MY-APP-1.js', function(err, proc) {
    if (err) throw new Error('err');

    pm2.disconnect(function() { 
      process.exit(0) 
    });
  });
})

Then launch this file with node and do a simple pm2 list. The process MY-APP-1.js is backgrounded.

More information here: https://github.com/Unitech/PM2#using-pm2-programmatically

And for the next release (the 1.0!) the programmatic interface will be usable via a promise style interface.

Standard Unix process behavior

Now you can pipe a pm2 to grep (or whetever), deploy it with Chef, Capistrano, Ansible or whatever, without any hassle. PM2 no longer needs to be already running on servers, just install it and you're done.

And so on

$ pm2 reset <name|id|all>  # Reset apps meta data

The entire changelog is available there: https://github.com/Unitech/PM2/blob/communication-protocol/CHANGELOG.md#0100---pm2-hellfire-release

Upgrading from older version

As the communication protocol has been refactored we added an automatic upgrade procedure on npm install.
To upgrade just do:

$ npm install pm2@latest -g

If you are logged as root, the installation may fail, because of preinstall and postinstall script. As explained in the error message, you must add the --unsafe-perm flag:

$ npm install pm2@latest -g --unsafe-perm

By the way you should't install PM2 as root!

If you experience any bug please fire an issue. Just in case you can't do anything, do a pkill -f pm2 and start PM2 again.

pm2-interface update

As the communication protocol has been upgraded, if you use pm2-interface in one of your project, don't forget to upgrade it to the 1.1.0 version.

Hope you like it!

We worked hard on this release. We continuously tested it with Travis, did many tests under uncommon conditions and on multiple servers. If you get any bugs or if you have any suggestion just fire an issue.

The 1.0 is upcoming with the imminent 0.12 Node.JS version!

And the monitoring dashboard is incoming! Be prepared to a completely new way to Monitor and Augment Node.JS!