registry_server.py :  » Web-Services » RPyC » rpyc-3.0.7 » rpyc » servers » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Services » RPyC 
RPyC » rpyc 3.0.7 » rpyc » servers » registry_server.py
#!/usr/bin/env python
"""
The registry server listens to broadcasts on UDP port 18812, answering to
discovery queries by clients and registering keepalives from all running 
servers. In order for clients to use discovery, a registry service must
be running somewhere on their local network.
"""
from optparse import OptionParser
from rpyc.utils.registry import REGISTRY_PORT,DEFAULT_PRUNING_TIMEOUT
from rpyc.utils.registry import UDPRegistryServer,TCPRegistryServer


parser = OptionParser()
parser.add_option("-m", "--mode", action="store", dest="mode", metavar="MODE",
    default="udp", type="string", help="mode can be 'udp' or 'tcp'")
parser.add_option("-p", "--port", action="store", dest="port", type="int", 
    metavar="PORT", default=REGISTRY_PORT, help="specify a different UDP/TCP listener port")
parser.add_option("-f", "--file", action="store", dest="logfile", type="str", 
    metavar="FILE", default=None, help="specify the log file to use; the default is stderr")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", 
    default=False, help="quiet mode (no logging)")
parser.add_option("-t", "--timeout", action="store", dest="pruning_timeout", 
    type="int", default=DEFAULT_PRUNING_TIMEOUT, help="sets a custom pruning timeout")

options, args = parser.parse_args()
if args:
    raise ValueError("does not take positional arguments: %r" % (args,))

if options.port < 1 or options.port > 65535:
    raise ValueError("invalid TCP/UDP port %r" % (options.port,))

if options.mode.lower() == "udp":
    server = UDPRegistryServer(port = options.port, 
        pruning_timeout = options.pruning_timeout)
elif options.mode.lower() == "tcp":
    server = TCPRegistryServer(port = options.port, 
        pruning_timeout = options.pruning_timeout)
else:
    raise ValueError("invalid mode %r" % (options.mode,))

server.logger.quiet = options.quiet
if options.logfile:
    server.logger.console = open(options.logfile)

server.start()


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.