pm2-service-discovery
v1.0.1
Published
PM2 Module for Service Discovery
Downloads
8
Readme
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