New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

warmup

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warmup

Warmup server apps by hitting URLs or performing tasks

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
81
-58.25%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

server

FAQs

Package last updated on 26 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts