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

watchpuppy

v2.0.0

Published

An almost fully grown watchdog for node.js

Downloads

10

Readme

Watchpuppy 🐶

An almost fully grown watchdog for node.js

This is a simple watchdog for node.js. It has no external dependencies and runs within the node process itself. This is not meant to replace something like an external health check service or a more advanced tool like foreverjs.

But sometimes you just need to keep an eye out on a simple worker script and make sure it is stil crunching data.

It is kept simple, i.e. there are no dependencies, just plain simple JavaScript (ES6).

Pull requests welcome.

Install

npm install watchpuppy

Usage

Simple example checking every 5 minutes and exiting the process if there weren't at least two pings:

const Watchpuppy = require('watchpuppy');

//setup watchpuppy

//defaults:
// checkInterval: 10000 (10s)
// minPing: 1
// stopOnError: true (stop the watchpuppy when a check fails)

//example:
// check every 5 minutes (checkInterval in ms)
// require at least two pings in the 5 min window
// stop checking after first error
// exit process on error

const options = {checkInterval: 5 * 60 * 1000, minPing: 1, stopOnError: true};
const callback = (err) => {
  console.error(err);
  process.exit(1);
};

const watchpuppy = new Watchpuppy(options, callback);

//fire a ping whenever you know things are running fine, e.g. somewhere in your stream processing
watchpuppy.ping();

//you can modify the weight of a ping by passing in a number
watchpuppy.ping(5); //equivalent to firing watchpuppy.ping() five times

//you can also invalidate a ping by passing in a negative number
watchpuppy.ping(-1); //doesn't do anything

Another example that doesn't stop on the first failure and simply logs errors to the console:

const Watchpuppy = require('watchpuppy');

const options = {stopOnError: false, minPing: 5};
const callback = (err) => {
  //err is a js Error with a message such as: 'only 3 pings received since last check'
  console.log(err.message);
};

const watchpuppy = new Watchpuppy(options, callback);

License

This module is licensed under the MIT license.