frontend: better handling of slave errors

Slave errors must NOT stop processing of other slaves
parent b6e6aab0
...@@ -33,6 +33,7 @@ import zc.buildout ...@@ -33,6 +33,7 @@ import zc.buildout
import zc.recipe.egg import zc.recipe.egg
import ConfigParser import ConfigParser
import re import re
import traceback
class Recipe(BaseSlapRecipe): class Recipe(BaseSlapRecipe):
...@@ -78,7 +79,7 @@ class Recipe(BaseSlapRecipe): ...@@ -78,7 +79,7 @@ class Recipe(BaseSlapRecipe):
# Future work may allow to choose between http and https (or both?) # Future work may allow to choose between http and https (or both?)
scheme = 'http://' scheme = 'http://'
self.logger.info('processing slave instance: %s' % reference) self.logger.info('Processing slave instance: %s' % reference)
# Check for mandatory slave fields # Check for mandatory slave fields
if backend_url is None: if backend_url is None:
...@@ -89,10 +90,13 @@ class Recipe(BaseSlapRecipe): ...@@ -89,10 +90,13 @@ class Recipe(BaseSlapRecipe):
# Check for custom domain (like mypersonaldomain.com) # Check for custom domain (like mypersonaldomain.com)
# If no custom domain, use generated one. # If no custom domain, use generated one.
# Note: if we get an empty custom_domain parameter, we ignore it # Note: if we get an empty custom_domain parameter, we ignore it
domain = slave_instance.get('custom_domain').strip() domain = slave_instance.get('custom_domain')
if domain is None or domain == '': if isinstance(domain, basestring):
domain = domain.strip()
if domain is None or domain.strip() == '':
domain = "%s.%s" % (reference.replace("-", "").lower(), domain = "%s.%s" % (reference.replace("-", "").lower(),
frontend_domain_name) frontend_domain_name)
# Define the URL where the instance will be available # Define the URL where the instance will be available
# WARNING: we use default ports (443, 80) here. # WARNING: we use default ports (443, 80) here.
slave_dict[reference] = "%s%s/" % (scheme, domain) slave_dict[reference] = "%s%s/" % (scheme, domain)
...@@ -152,7 +156,13 @@ class Recipe(BaseSlapRecipe): ...@@ -152,7 +156,13 @@ class Recipe(BaseSlapRecipe):
# Send connection informations about each slave # Send connection informations about each slave
for reference, url in slave_dict.iteritems(): for reference, url in slave_dict.iteritems():
self.setConnectionDict(dict(site_url=url), reference) self.logger.debug("Sending connection parameters of slave "
"instance: %s" % reference)
try:
self.setConnectionDict(dict(site_url=url), reference)
except:
self.logger.fatal("Error while sending slave %s informations: %s",
reference, traceback.format_exc())
# Then set it for master instance # Then set it for master instance
self.setConnectionDict( self.setConnectionDict(
...@@ -454,7 +464,7 @@ class Recipe(BaseSlapRecipe): ...@@ -454,7 +464,7 @@ class Recipe(BaseSlapRecipe):
return stunnel_conf return stunnel_conf
def installFrontendApache(self, ip_list, key, certificate, name, def installFrontendApache(self, ip_list, key, certificate, name,
port=4443, plain_http_port=8080, port=4443, plain_http_port=8080,
rewrite_rule_list=[], rewrite_rule_zope_list=[], rewrite_rule_list=[], rewrite_rule_zope_list=[],
access_control_string=None): access_control_string=None):
# Create htdocs, populate it with default 404 document # Create htdocs, populate it with default 404 document
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment