New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rutilus-apiheartbeat-node

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rutilus-apiheartbeat-node

Makes constant requests to urls and logs whether the response was successful and the response time. Can be configured to throw errors if the response fails in order to crash containers.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Rutilus - API Heartbeat - Node

This module makes constant requests to urls and logs whether the response was successful and the response time.

The module can be set to throw errors if the URL does not respond in order to crash containers.

Example: if we are deploying a cluster of containers with several APIs and want to make sure all the APIs are responding properly, we can set up this module to watch all the APIs and throw an error to crash the container (which will be restarted) in case one of them stops responding.

This module does not have dependencies.

Installing

npm install rutilus_apiheartbeat_node --save

Using

Require the module in the project and call it by passing 2 parameters, the last one being optional:

First parameter

An array of objects that describe the APIs to be monitored:

[
    {
        title: String (optional, defaults to "Untitled"),
        address: String,
        useHttps: true (optional, defaults to "false"),
        logDirectory: '/logs' (optional, defaults to ""),
        logFile: String,
        timeSpan: Number (optional, defaults to "10000"),
        maxFileSizeBytes: Number (optional, defaults to "10000000"),
        crashWhenFail: Boolean (optional, defaults to "false"),
    }
]
  • title: A meaningful title for the API
  • address: The URL of the api
  • useHttps: Use HTTP or HTTPS for making the request?
  • logDirectory: Directory where the logs must be saved
  • logFile: Name of the file for the logs
  • timeSpan: Time span (ms) for every heartbeat. Minimum: 10 seconds.
  • maxFileSizeBytes: Maximum size for the log file - when the size exceeds the one specified, the old logs get archived ("ARCHIVE_" + log file name). If there already is an archived version, it gets overwritten.
  • crashWhenFail: If set to true, when an API fails, this module will throw an error. Useful for crashing containers and making them restart.

Second parameter (optional, defaults to 0)

A number that delays the start of the heartbeat. Example: 10000 (for 10 seconds)

Example

const APIHeartbeat = require('rutilus_apiheartbeat_node');

APIHeartbeat([{
    title: 'My API 1',
    address: 'https://www.api1.com/',
    useHttps: true,
    logDirectory: '/logs',
    logFile: 'api1.log',
    timeSpan: 10000,
    maxFileSizeBytes: 1000000,
    crashWhenFail: true,
}, {
    title: 'My API 2',
    address: 'http://www.api2.com:3000/',
    useHttps: false,
    logDirectory: '/logs/api2',
    logFile: 'api2.log',
    timeSpan: 60000,
}], 5000);

Keywords

FAQs

Package last updated on 03 Feb 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc