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

skyboot

v0.4.0

Published

Start up app with SkyDNS and Config-Etcd

Downloads

6

Readme

SkyBoot Build Status Coverage Status npm version

Helper library for starting up and configuring apps with SkyDNS and Etcd.

NPM

Methods

skyboot.init(config, callback);

Initializes the config. Once everything has been set up it runs callback. Everything that depends on the config should be run inside that callback.

skyboot.getSrv(service, cb(err, record) );

Looks up the DNS SRV record and returns a random service from the list of services.

record will be in the form:

{ host: 'hostname.service.skydns.local', port: 8080}

skyboot.config(key)

Access the config object with the optional key:

skyboot.log()

Get the log object.

Config Explanation

SkyBoot expands values that begin with etcd: or srv: into the values received from the etcd or the DNS srv records.

For example:

{
  etcd_service: 'etcd-4001.skydns.local',
  db: {
    server: 'srv:redis.skydns.local'
    password: 'etcd:/services/db/password'
  }
}

Will be expanded to:

{
  etcd_service: 'etcd-4001.skydns.local',
  db: {
    server: { host: 'redis1.redis.skydns.local', port: 1337 }
    password: 'mysuperpass'
  }
}

Special Keys

etcd_service: ""

Defines a DNS SRV record to look up etcd servers. The results will then override etcd_hosts.

etcd_hosts: []

A list of etcd servers in the format 'host:port'.

If etcd_hosts and etcd_service are empty etcd: config values will not expand but initialization will complete.

srv_records: {}

Custom prefilling of dns lookup results for config expansion and getSrv().

This is mostly useful for local development that might not have access to the right DNS and when controlled results are required from config expansion and getSrv().

log: SimpleLogger

Set a logging object. This object will be used by SkyBoot for messages.

Quick Example

Simple standalone example:

var http = require('http');
var request = require('request');
var skyboot = require('skyboot');
var mqtt = require('mqtt');
var config_template = {
  etcd_service: 'etcd-4001.skydns.local',
  mqtt: 'srv:mqtt.skynds.local',
  port: 'etcd:/apps/myservice/port',
  github: { api_key: 'etcd:/apps/github/api_key' }
};

skyboot.init(config_template, function () {
  var mqtt_config = skyboot.config('mqtt');
  mqtt.connect(mqtt_config.port, mqtt_config.host);
  var server = http.createServer().listen(skyboot.config().port);
  skyboot.getSRV('metrics.skynds.local', function (err, service) {
    var url = ['http://', service.host, ':', service.port, '/announce/server_start'].join();
    request.post(url, { listening: 'myserver', port: skyboot.config().port });
  });
});

Works wonderfully with other boot phase libs like bootable or onboot:

var onboot = require('onboot');
var skyboot = require('skyboot');

onboot.strap(function (done) {
  var config_template = {
    etcd_service: 'etcd-4001.skydns.local',
    mqtt: 'srv:mqtt.skynds.local',
    port: 'etcd:/apps/myservice/port'
  };
  skyboot.init(config_template, done);
})
onboot.strap(function (done) {
  // Do other async pre stuff
});

onboot.up(function () {
  mqtt.connect(skyboot.config().mqtt.port, skyboot.config().mqtt.host);
  // ... Do all your stuff like starting a http server listener
});