pm2-service-discovery

1.0.1 • Public • Published

pm2-service-discovery

Synchronize services from consul to nodejs app managed by PM2.

How it works

This module propagate services changes using an event bus to services managed by PM2.

The module send config update to application :

  • Pragmatically when
    • PM2 start
    • PM2 launch a new service
    • Consul have a new configuration
  • Manually : pm2 trigger pm2-microservice reload

Sample

When the module is installed... in you code managed by pm2 :

process.on('message', (rs, err) => {
  if(err) return;
  if(rs && rs.topic === 'service:update') {
    const services = rs.data || [];

    console.log(JSON.stringify(services, null, 4));
  }
});

Configuration

key type default Description
service enum(consul) consul
consul object {}
consul.url url http://localhost:8500

Commands

reload : Ask Consul for config update

Readme

Keywords

none

Package Sidebar

Install

npm i pm2-service-discovery

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • iam-merlin