示例#1
0
 def launch_server(cls):
     if not cls.check_server_is_alive():
         log_file = os.path.join(user_log_dir('PyXRD'), 'server.log')
         start_script("run_server.py", auto_kill=not settings.KEEP_SERVER_ALIVE, log_file=log_file)
         ttl = 15
         delay = 0.2
         while not cls.check_server_is_alive():
             time.sleep(delay) # wait
             ttl -= 1
             if ttl == 0:
                 raise ServerStartTimeoutExcecption("Pyro4 PyXRD Server is not running!")
         logging.info("Pyro4 PyXRD server is running!")
         if not settings.KEEP_SERVER_ALIVE:
             atexit.register(cls.stop_server)
示例#2
0
 def launch_server(cls):
     if not cls.check_server_is_alive():
         log_file = os.path.join(user_log_dir('PyXRD'), 'server.log')
         start_script("run_server.py",
                      auto_kill=not settings.KEEP_SERVER_ALIVE,
                      log_file=log_file)
         ttl = 15
         delay = 0.2
         while not cls.check_server_is_alive():
             time.sleep(delay)  # wait
             ttl -= 1
             if ttl == 0:
                 raise ServerStartTimeoutExcecption(
                     "Pyro4 PyXRD Server is not running!")
         logging.info("Pyro4 PyXRD server is running!")
         if not settings.KEEP_SERVER_ALIVE:
             atexit.register(cls.stop_server)
示例#3
0
    from pyxrd.server.utils import start_script
    from pyxrd.logs import setup_logging
    setup_logging(basic=True, prefix="PYRO SERVER:")

    import Pyro4
    try:
        from Pyro4.naming import NamingError
    except (AttributeError, ImportError):
        from Pyro4.errors import NamingError


    server = PyXRDServer()

    daemon = Pyro4.Daemon()

    try:
        ns = Pyro4.locateNS()
    except NamingError:
        logger.info("NamingError encountered when trying to locate the nameserver")
        log_file = os.path.join(user_log_dir('PyXRD'), 'nameserver.log')
        start_script("start_nameserver.py", auto_kill=not settings.KEEP_SERVER_ALIVE, log_file=log_file)
        ns = Pyro4.locateNS()

    server_uri = daemon.register(server)
    ns.register(settings.PYRO_NAME, server_uri) # settings.PYRO_NAME)

    try:
        daemon.requestLoop(server.loopCondition)
    finally:
        daemon.shutdown()
示例#4
0
from . import settings

if __name__ == "__main__":

    from pyxrd.logs import setup_logging
    setup_logging(basic=True, prefix="PYRO SERVER:")
    
    import logging
    logger = logging.getLogger(__name__)

    server = PyXRDServer()

    daemon = Pyro4.Daemon()

    try:
        ns = Pyro4.locateNS()
    except Pyro4.naming.NamingError:
        logger.info("NamingError encountered when trying to locate the nameserver")
        log_file = os.path.join(user_log_dir('PyXRD'), 'nameserver.log')
        start_script("start_nameserver.py", auto_kill=not settings.KEEP_SERVER_ALIVE, log_file=log_file)
        ns = Pyro4.locateNS()

    server_uri = daemon.register(server)
    ns.register(settings.PYRO_NAME, server_uri) # settings.PYRO_NAME)

    try:
        daemon.requestLoop(server.loopCondition)
    finally:
        daemon.shutdown()