Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


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


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.


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.


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.


Enable verbose logging to standard out.


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


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



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




No releases published


No packages published
You can’t perform that action at this time.