Skip to content
This repository was archived by the owner on Jan 17, 2022. It is now read-only.

e-conomic/etcd-registry-join

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived

Tech Leads: Repository archived due to inactivity in more than 6 months. Please remember to add a CODEOWNERS file to the root of the repository when unarchiving.

etcd-registry-join

Add a service to etcd-registry and remove it when your service process exits

npm install etcd-registry-join

Or if you want to install the command line tool as well

npm install -g etcd-registry-join

Usage

var join = require('etcd-registry-join');
var http = require('http');

var server = http.createServer(function(request, response) {
	response.end('hello world\n');
});

server.listen(8080, function() {
	join('http://127.0.0.1', 'my-service', server, function(err, service) {
		console.log('service joined:', service);
	});
});

You should replace http://127.0.0.1 with your connection string to etcd. Alternatively you can pass an instance of etcd-registry.

When the process receives SIGTERM or SIGINT it will unregister the service from the registry before exiting the process.

Command line usage

You can also use the command line tool

etcd-registry-join http://127.0.0.1 my-service my-app.js

Where my app looks like

var http = require('http');
var server = http.createServer(function(request, response) {
	response.end('hello world\n');
});

server.listen(process.env.PORT); // this env var is set by etcd-registry-join

When your server is listening on PORT etcd-registry-join will add your service to the registry

License

MIT

About

Add a service to etcd-registry and remove it when your service process exits

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%