Skip to content

markushedvall/node-nailgun-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-nailgun-server

A Node.js module for running Nailgun servers.

npm Version Build Status js-standard-style

This package enable you to run Nailgun servers through your Node.js applications.

Note that this only provides support for running Nailgun servers. If you are need of a Nailgun client for Node.js, node-nailgun-client is recommended.

Install

npm install node-nailgun-server

Example

By the default the server will listen to all interfaces on port 2113.

const nailgun = require('node-nailgun-server');

const server = nailgun.createServer();
server.out.pipe(process.stdout);

In the following example node-nailgun-client is used to communicate with the server:

const nailgun = require('node-nailgun-server');
const client = require('node-nailgun-client');

const options = {
  address: 'localhost',
  port: 0, // 0 lets the server choose a random port
}

nailgun.createServer(options, function(port) {
  const nail = client.exec('ng-stats', { port: port })
  nail.stdout.pipe(process.stdout);
});

The server object returned when creating a server provides a output stream and also a function for shutting the server down:

server.shutdown();

Servers are also shutdown automatically when the Node.js process exits.

License

Apache License 2.0

About

A Node.js module for running Nailgun servers

Resources

License

Stars

Watchers

Forks

Packages

No packages published