ia64/xen-unstable

changeset 12808:c4824dcd57c4

Fix server reloading when the HTTP server is enabled.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Dec 06 10:37:10 2006 +0000 (2006-12-06)
parents 258722281202
children 92127156ec49
files tools/python/xen/xend/server/SrvServer.py
line diff
     1.1 --- a/tools/python/xen/xend/server/SrvServer.py	Wed Dec 06 10:13:46 2006 +0000
     1.2 +++ b/tools/python/xen/xend/server/SrvServer.py	Wed Dec 06 10:37:10 2006 +0000
     1.3 @@ -62,8 +62,9 @@ xroot = XendRoot.instance()
     1.4  
     1.5  class XendServers:
     1.6  
     1.7 -    def __init__(self):
     1.8 +    def __init__(self, root):
     1.9          self.servers = []
    1.10 +        self.root = root
    1.11          self.cleaningUp = False
    1.12          self.reloadingConfig = False
    1.13  
    1.14 @@ -101,6 +102,9 @@ class XendServers:
    1.15          while True:
    1.16              threads = []
    1.17              for server in self.servers:
    1.18 +                if server.ready:
    1.19 +                    continue
    1.20 +
    1.21                  thread = Thread(target=server.run, name=server.__class__.__name__)
    1.22                  if isinstance(server, HttpServer):
    1.23                      thread.setDaemon(True)
    1.24 @@ -156,21 +160,23 @@ class XendServers:
    1.25                      pass
    1.26  
    1.27              if self.reloadingConfig:
    1.28 -                log.info("Restarting all servers...")
    1.29 +                log.info("Restarting all XML-RPC and Xen-API servers...")
    1.30                  self.cleaningUp = False
    1.31                  self.reloadingConfig = False
    1.32                  xroot.set_config()
    1.33 -                self.servers = []
    1.34 -                _loadConfig(self)
    1.35 +                new_servers = [x for x in self.servers
    1.36 +                               if isinstance(x, HttpServer)]
    1.37 +                self.servers = new_servers
    1.38 +                _loadConfig(self, self.root, True)
    1.39              else:
    1.40                  break
    1.41  
    1.42 -def _loadConfig(servers, root):
    1.43 -    if xroot.get_xend_http_server():
    1.44 +def _loadConfig(servers, root, reload):
    1.45 +    if not reload and xroot.get_xend_http_server():
    1.46          servers.add(HttpServer(root,
    1.47                                 xroot.get_xend_address(),
    1.48                                 xroot.get_xend_port()))
    1.49 -    if xroot.get_xend_unix_server():
    1.50 +    if not reload and xroot.get_xend_unix_server():
    1.51          path = xroot.get_xend_unix_path()
    1.52          log.info('unix path=' + path)
    1.53          servers.add(UnixHttpServer(root, path))
    1.54 @@ -218,6 +224,6 @@ def _loadConfig(servers, root):
    1.55  def create():
    1.56      root = SrvDir()
    1.57      root.putChild('xend', SrvRoot())
    1.58 -    servers = XendServers()
    1.59 -    _loadConfig(servers, root)
    1.60 +    servers = XendServers(root)
    1.61 +    _loadConfig(servers, root, False)
    1.62      return servers