SkyBoot
Helper library for starting up and configuring apps with SkyDNS and Etcd.
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 = ;var request = ;var skyboot = ;var 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;
Works wonderfully with other boot phase libs like bootable or onboot:
var onboot = ;var skyboot = ; onbootonboot; onboot;