Skip to content

Instantly share code, notes, and snippets.

@lekkas
Created October 7, 2016 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lekkas/1249adf9a93abb71ad6cb7577691ba9f to your computer and use it in GitHub Desktop.
Save lekkas/1249adf9a93abb71ad6cb7577691ba9f to your computer and use it in GitHub Desktop.
service discovery
{ 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