npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adios

v2.1.0

Published

A simple module for handling shutdowns within a clustered application.

Downloads

42

Readme

Adios

Greenkeeper badge

Build Status Coverage Status

A module for notifying clustered workers for clean shutdowns.

This is accomplished by using domain sockets/var/run/adios.sock by default – which has the added benefit of not sending messages over application specific IPC channels. This means you don't have to filter out messages from adios in any process.on('message') listeners.

Note: On Windows, the local domain is implemented using a named pipe. The path must refer to an entry in \\?\pipe\ or \\.\pipe\. Therefore, you must initialize adios with a path in this space if you are running on a Windows machine.

Usage

'use strict';
const cluster = require('cluster');
const http = require('http');
const Adios = require('adios');

if (cluster.isMaster) {
  Adios.master.init()
    .then(() => {
      let worker = cluster.fork();
    });
}
else {
  let server = http.createServer();
  Adios.child.init(() => {
    return new Promise(resolve => {
      server.close(resolve);
    });
  })
    .then(() => {
      server.listen(3000);
    });
}

API

  • Adios.master.init([path]) - The initialize function for adios masters. Sets up a server for IPC with clustered workers. Note: there can be only one.

    • path - (optional) The socket path to use. Defaults to /var/run/adios.sock
    • config - (optional) A configuration object for the master process. Contains:
      • timeout: time in milliseconds before a child will be force closed. Default: 10000, 10 seconds.

    Returns a promise that resolves when the server is listening.

  • Adios.master.kill(pid) - Method to kill a worker by process id

    • pid - The process id to kill
  • Adios.master.term(pid) - Method to terminate a worker by process id, this will call the graceful shutdown defined by the worker.

    • pid - The process id to terminate

    Returns a promise that resolves when the worker is terminated.

  • Adios.child.init(cleanCb[, path]) - The initialize function for adios children. Sets up a connection to the master. Note: there can be only one per process and it must be running on a child process.

    • cleanCb - The method to execute when the master is notifying of a shutdown. Must return a promise that resolves when work is done.
    • path - (optional) The socket path to use. Defaults to /var/run/adios.sock

    Returns a promise that resolves when the connection with the master has been established.