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

restart-o-meter

v0.0.3

Published

Detect process "restarts" (as opposed to just "starts") in node.js processes.

Downloads

1

Readme

restart-o-meter

Build
Status Coverage Status

Detect process "restarts" (as opposed to just "starts") in node.js processes in a cluster. A 'start' is anytime a process in the cluster starts. A 'restart' is anytime a process in the cluster restarts after the last master 'start'. I use this with cluster-master, but it can probably be used with any clustering solution, including node.js's standard cluster module. This module requires some minimal file i/o to maintain application state between server restarts, so you'll need read/write access to some path for this to work.

Basic set-up:

var restartOMeter = require('restart-o-meter')({
  secondsToBoot : 20,
  filePath : '/tmp/STARTED',
  onRestart : function(){
    console.log("detected a restart!");
  },
  verbose : true
});

secondsToBoot

This is your way of indicating how long the application should take to start, in seconds. During this time, no 'starts' will be counted as 'restarts'. After this time, all 'starts' will be counted as 'restarts' until masterStart() is called again. This is not a required property, as it will default to 30 seconds. You want this to be long enough that regular process boot-time isn't longer than the duration causing false restart detections, but also short enough that if a process gets stuck in a restart loop, you can detect it as fast as possible.

filePath

This is the path to the temporary file that is used to denote that the process has been started. It exists despite reboots so that the restart-o-meter can tell if a 'start' is actually a 'restart'. This is not a required property as it will default to /tmp/STARTED. NB: If the filepath that you use is not writable by the user that your process runs as, then this will not work.

onRestart

This is a callback that gets called when a restart is detected. You can put logging or metrics in this. It's not a required option, but it's really the whole point of this module.

verbose

Enable verbose logging to standard out.

Usage:

Call masterStart() at the earliest point in your code possible. eg:

restartOMeter.masterStart();

Call childStart() at the earliest point in your child process code, possible. eg:

restartOMeter.childStart();