Example #1
0
 def __init__(self, serialized_path, reload_time=15, ring_name=None):
     # Can't use the ring unless the on-disk configuration is valid
     validate_configuration()
     if ring_name:
         self.serialized_path = os.path.join(serialized_path,
                                             ring_name + '.ring.gz')
     else:
         self.serialized_path = os.path.join(serialized_path)
     self.reload_time = reload_time
     self._reload(force=True)
Example #2
0
    def run(self, once=False, **kwargs):
        """Run the daemon"""
        ondisk.validate_configuration()
        utils.drop_privileges(self.conf.get('user', 'swift'))
        utils.capture_stdio(self.logger, **kwargs)

        def kill_children(*args):
            signal.signal(signal.SIGTERM, signal.SIG_IGN)
            os.killpg(0, signal.SIGTERM)
            sys.exit()

        signal.signal(signal.SIGTERM, kill_children)
        if once:
            self.run_once(**kwargs)
        else:
            self.run_forever(**kwargs)
Example #3
0
def _initrp(conf_path, app_section, *args, **kwargs):
    try:
        conf = appconfig(conf_path, name=app_section)
    except Exception as e:
        raise ConfigFileError("Error trying to load config from %s: %s" %
                              (conf_path, e))

    validate_configuration()

    # pre-configure logger
    log_name = conf.get('log_name', app_section)
    if 'logger' in kwargs:
        logger = kwargs.pop('logger')
    else:
        logger = get_logger(conf, log_name,
                            log_to_console=kwargs.pop('verbose', False),
                            log_route='wsgi')

    # disable fallocate if desired
    if config_true_value(conf.get('disable_fallocate', 'no')):
        disable_fallocate()

    monkey_patch_mimetools()
    return (conf, logger, log_name)