Socket
Book a DemoInstallSign in
Socket

childport

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

childport

Launch child processes for services that bind to a specified port.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

childport

Launch child processes for services that bind to a specified port.

npm install childport

// parent.js
var request = require('request')
  , childport = require('childport')
  ;

function finish (e, p) {
  request('http://localhost:3001', function (e, resp, body) {
    if (e) throw e
    if (resp.statusCode !== 200) throw new Error('status not 200, ', resp.statusCode)
  })
}

var child = childport.cp(3001, finish).spawn('node', [__dirname+'/child.js'])
child.on('error', function (e) {throw e})
child.stderr.pipe(process.stderr)
// child.js
var http = require('http')
  , childport = require('../')
  ;

childport.listen(http.createServer(function (req, resp) {
  resp.statusCode = 200
  resp.end('ok')
}))

childport.listen(server)

This method is to be used in child process scripts. It will parse the specified port and call listen on the server it sent and, on success, let the parent process know it has finish so that it can resolve the specified callback.

Returns the server it was passed for easy chaining.

childport.child_process(port, cb) && childport.cp(port, cb)

Returns a mocked child_process module that will launch the process with identifying information about the port to bind to.

childport.cp(port, cb).spawn

Identical to core's child_process.spawn.

childport.cp(port, cb).fork

Identical to core's child_process.fork.

childport.cp(port, cb).exec

Identical to core's child_process.exec.

childport.cp(port, cb).execFile

Identical to core's child_process.execFile.

Keywords

child

FAQs

Package last updated on 16 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts