JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 171953
  • Score
    100M100P100Q195812F
  • License ISC

Terminate a Node.js Process based on the Process ID

Package Exports

  • terminate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (terminate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

terminate

A reliable (tested) way to Terminate a Node.js Process (and all Child Processes) based on the Process ID

terminate-the-node-process-final

Build Status Code Climate Test Coverage npm version [![Node.js Version][node-version-image]][node-version-url] Dependency Status [node-version-image]: https://img.shields.io/node/v/listdirs.svg?style=flat [node-version-url]: http://nodejs.org/download/

Usage

Install from NPM

npm install terminate --save

In your script

var terminate = require('terminate');
terminate(process.pid, function(err, done){
  if(err) { // you will get an error if you did not supply a valid process.pid
   console.log("Oopsy: " + err); // handle errors in your preferred way.
 }
 else {
   console.log(done); // do what you do best!
 }
})

tl;dr

Why?

In our Faster project we run the server using a child process. When we want to re-start the server,
we needed to ensure the process (and any Child Processes) were Terminateed before re-start.

Research

Background Reading

Useful StackOverflow Questions/Answers

Background / Motivation

While building the Faster module we decided to use Child Process(es) to run the application we are observing.
As a result, we need to be able to kill those processes in order to re-start the app.

Why not use an Existing Module?

We investigated using terminate: https://github.com/indexzero/terminate/ it was un-maintained and had no tests so we submitted an issue offering to update the module with tests.
Charlie replied welcoming an update so we submitted a Pull Request with 100% test coverage

Other potential modules:

Name

Terminate seemed like the best (of the available) name,
if you have a better suggestion, please share!



## This Project Reminded me of Two *xkcd* Comics:

xkcd terminate

xkcd time robot