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

autohost-canary

v0.1.1

Published

An endpoint for getting service status updated via postal

Downloads

13

Readme

autohost-canary

Adds an end-point for tracking in-depth status of a service. Services determine what gets reported as status via API.

Installation & Setup

npm install autohost-canary -S
var autohost = require( "autohost" );
var host;
var hyped = require( "hyped" )();
var fount = require( "fount" );
var postal = require( "postal" );
// create the channel used to communicate between
// various components and the status tracker
var channel = postal.channel( "ahcanary" );

fount.register( "ahcanary", channel );
host = hyped.createHost( autohost, {
	port: config.nonstop.host.port,
	modules: [
		"autohost-canary"
	],
	fount: fount
}, function() {
	host.start();
} );

// by publishing a status to a topic, the status tracker will update its state
// where topic is the key and the message will be the value. This is a very simple
// way to get a quick glimpse into what's happening. See status messages for more
// details on how to control status.

// this example demonstrates tracking rabbit connectivity:
rabbit.on( "connected", function( msg ) {
	channel.publish( "rabbit", { value: "connected" } );
} );

rabbit.on( "closed", function( msg ) {
	channel.publish( "rabbit", { value: "closed" } );
} );

rabbit.on( "failed", function( msg ) {
	channel.publish( "rabbit", { value: "connection failed" } );
} );

HTTP API

The only thing you can do is get the status:

GET /api/ah/status

If you're using hyped then you can access the same endpoint via status:self. The names and routes were chosen to make the chance of collision extremely low.

The result will be a JSON object with your keys/values and a few bonus items:

{
	// your stuff here ...
	"memory": { a hash containing memory usage details },
	"uptime": "a human readable duration",
	"version": "a version specifier from your package.json OR nonstop-info"
}

Status Messages

You get a little more control on what status is reported based on how you format your message.

Default

You can publish a message with default to tell canary that if the key is removed or reset to still display the key with the default value.

channel.publish( "database", { default: "pending" } );

Reset

Publishing this message will cause the key to revert to undefined or a previously provided default value.

channel.publish( "key", { reset: true } );

Value

Updates the current status for the topic to the value provided.

channel.publish( "usersConnected", x );

Time to live (milliseconds)

Some values are only good for a period of time or don't have a compensating event to tell you when the value has changed. To address this, you can put a ttl property on the message body which will cause the value to be removed from status or revert to a previously assigned default.

channel.publish( "processingMessages", value: true, ttl: 100 )