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

warmup

v1.2.0

Published

Warmup server apps by hitting URLs or performing tasks

Downloads

14,325

Readme

warmup

Simple module to warmup a server application (such as an Express app) by hitting server URLs and performing various tasks. This module also allows a worker to be warmed up before it is added to a cluster.

Installation

npm install warmup

Usage

var warmup = require('warmup');
warmup(app, tasks, callback);
warmup(app, tasks, options, callback);

Simple example of warming up an Express server application:

var warmup = require('warmup');
var express = require('express');

var app = express();

// ...

warmup(
    app,
    [
        '/foo', // A URL to hit to warmup the server
        '/bar', // A URL to hit to warmup the server
        {
            path: '/baz', // Required
            headers: {
                'User-Agent': 'xxx'
            }
        },
        function myFunc(callback) { // A custom warmup task
            var port = this.port; // The warmup port is there if you need it
            callback();
        },
        {
            name: 'My long task', // You can give a task a name for debugging purposes
            func: function(callback) {
                setTimeout(function() {
                    callback();
                }, 1200);
            },
            timeout: 2000 // Override the default task timeout
        }
    ],
    {
        timeout: 1000 // Set a default task timeout
    }
    function(err) {
        if (err) {
            // handle error
        }
        app.listen(8080);
    });

Passing the warmup tasks information:

  • string: as a string that contains the path of the url to make a GET request to during warmup, e.g. '/foo'
  • object: as an object if you want to pass additional properties like headers to the request object. Be sure to pass a path property at the bare minimum when passing the request information in this case

The following options are supported:

  • timeout - Timeout for each task (defaults to 10s)
  • warmupPort - The warmup port to use (defaults to a random port in the range of [10,000-50,000])

The warmup module works by starting the app on a random HTTP port. This allows the application to be started without accepting traffic.

NOTES:

  • All of the tasks are executed in parallel
  • The default timeout is 10s