Created
October 7, 2016 07:06
-
-
Save lekkas/1249adf9a93abb71ad6cb7577691ba9f to your computer and use it in GitHub Desktop.
service discovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ enumerateServices, findServices } = require './lib/discoverable' | |
AVAHI_RESIN_SSH_TAG = 'resin-ssh' | |
enumerateServices() | |
.then (availableServices) -> | |
services = [] | |
for s in availableServices | |
services.push(s.service) if AVAHI_RESIN_SSH_TAG in s.tags | |
return services | |
.then (services) -> | |
if not services? or services.length is 0 | |
throw new Error('Could not find any available services with tag:', AVAHI_RESIN_SSH_TAG) | |
console.log 'Looking for ', services | |
findServices(services, 30000) | |
.then (discovered) -> | |
console.log discovered |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment