Coder Social home page Coder Social logo

paramedic's Introduction

Paramedic

Deprecated: paramedic is very old and no longer maintained.

A simple health monitor server for running health checks periodically.

Installation

npm install paramedic

Usage

Step 1: Create a new server.

var medic = require('paramedic').createServer()

Step 2: Load up your tests. There are two callbacks passed to each test: done and warn. If you pass an error (or string) as the first argument to either of these callbacks, the test will fail: done emits an error, whereas warn only emits a warning.

var request = require('request')

medic.test('Google Australia', function(done, warn) {
    request.get('http://google.com.au/', function(err) {
        return done(err);
    });
}).interval(6000);

medic.test('Google UK', function(done, warn) {
    request.get('http://google.co.uk/', function(err) {
        return warn(err);
    });
}).interval(21000);

Step 3: Start up the server! start() returns a request callback for you to easily plug into an HTTP server, or as an Express route.

var http = require('http')
  , server = medic.start();

http.createServer(server).listen(8080);

After that, your server should be running on port 8080, similar to this:

Screenshot

Collections

You can create "collections" of tests too. These function as reusable templates, which can then be loaded using the collection's add method.

medic.collection('Google Queries', function(data) {
    this.test('http://google.com/?q=' + data.query, function(done, warn) {
        request.get(data.url, done);
    }).interval(data.interval);
}).add({
      query: 'lorem'
    , interval:  6000
}).add({
      query: 'lorem'
    , interval: 21000
});

Events

The server page will update accordingly as tests fail and recover, but the server also emits error, warn, pass and recover events.

This can be used, for example, to send notifications or automate a recovery.

ready is emitted when the server has started testing.

paramedic's People

Contributors

hughsk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.