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

imalive

v1.0.7

Published

Sends timestamp to database to report app is alive

Downloads

11

Readme

ImAlive

Sends timestamp to database to report app is alive.

Usage

Install with npm

npm install --save imalive
var imalive = require("imalive")

var options = {
    Hostname    : 'somehostname.com',
    DBName      : 'mydatabase',
    Dialect     : '', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
    Port        : 3306, /* 3306 is default port for mySql. Change it upon your needs */
    User        : 'myUser',
    Password    : 'myPassword',
    Table       : 'TableForMonitoringPurpose',
    ServiceName : 'ServiceReportingAliveState',
    Interval    : 5000, /* Optional. Nb. of ms between updates. If not specified, update will occur once */
    Logging     : true, /* Optional. If specified and true, detailed logging will be outputed to console. Otherwise, only errors will be outputed. */
    NbAddColumns: 3 /* Optional. If your destination table contains additional columns, specifie the number here, to make the insert command working when creating a new entry (Inserted values will be null, so columns must be nullable). */
};

imalive(
    options,
    function(err) {
        if (err) {
            console.error('ERROR: ', err);
        }
        else {
            console.log('SUCCESS!');
        }
    }
);

Table Definition

Table into which status is reported MUST be defined as following (Table name is up to you since it is defined into options):

Column ID | Column name | Definition / Comments ----------|-------------|---------------------- 1 | ID | PKey, int, Auto_Increment 2 | ServiceName | unique, varchar(50) 3 | HeartBeat | datetime n | Up to you | Up to you

Note: Columns 1 to 3 MUST have these names and definitions. Remaining columns names and definition are up to you. If you have additional columns, the number must be specified in options (parameter NbAddColumns). Otherwise, the initial INSERT (when adding a new service) will fail. These additional columns must be nullable in the database.

Behaviour of options.Interval

When an interval is specified and greater than zero (0), the module itself will send update requests to the database every nnnn milliseconds. If you prefer to control your update interval by yourself, just don't specify this option of set it to zero (0), and the module will send only one update request. Resist to the temptation to put a value smaller than 1000 (1 second) because the database will possibly reject most of your requests. Use a value that fits your needs, but since this is a database update, even if it is very light, the traffic, and the opening/closing connection action, could become an issue if this value is too small. Evaluate your needs to put the biggest possible value.

Testing status

Tested only with MySql/MariaDB database for the moment.

Upcoming changes

Raw queries will probably be changed for SequelizeJS models in the future.