Created
December 31, 2014 20:51
-
-
Save tylertreat/7851d763d99fb404100d to your computer and use it in GitHub Desktop.
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
import os | |
import time | |
from service_discovery import ServiceDiscovery | |
DEFAULT_PORT = 5555 | |
DEFAULT_DEADLINE = 5000 | |
DEFAULT_INTERVAL = 2000 | |
def start_discovery(port, deadline, interval): | |
discovery = ServiceDiscovery(port, deadline=deadline) | |
discovery.bind() | |
print 'Starting service discovery [port: %s, deadline: %s, interval: %s]' \ | |
% (port, deadline, interval) | |
while True: | |
print discovery.discover() | |
time.sleep(interval / 1000) | |
if __name__ == '__main__': | |
port = int(os.environ.get('PORT', DEFAULT_PORT)) | |
deadline = int(os.environ.get('DEADLINE', DEFAULT_DEADLINE)) | |
interval = int(os.environ.get('INTERVAL', DEFAULT_INTERVAL)) | |
start_discovery(port, deadline, interval) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment