예제 #1
0
config.add_log_handler(ch)
common.add_log_handler(ch)

config_file = os.getenv('LAUNCHER_CONFIG')
assert config_file is not None and os.path.isfile(config_file), "invalid LAUNCHER_CONFIG"

app.iniconfig = FlaskIni()
with app.app_context():
    app.iniconfig.read(config_file)

redis = RedisDatabase(app.iniconfig.get('redis','host'),
                      app.iniconfig.get('redis','port',fallback=6379),
                      app.iniconfig.get('redis','db',fallback=0),
                      app.iniconfig.get('redis', 'password',fallback=None))

retry = 0
while retry < 10:
    try:
        redis.get("test_connection")
        break
    except ConnectionError as e:
        retry += 1
        time.sleep(1)

assert retry < 10, "Cannot connect to redis DB - aborting"

services, base_config = config.load_services(app.iniconfig.get('default','config_dir'))

from app import routes
예제 #2
0
# connecting to redis to monitor the worker process
cfg = configparser.ConfigParser()
cfg.read('settings.ini')
redis_password = None
if cfg.has_option('redis', 'password'):
    redis_password = cfg.get('redis', 'password')
redis = RedisDatabase(cfg.get('redis', 'host'),
                      cfg.getint('redis', 'port'),
                      cfg.get('redis', 'db'),
                      redis_password)


retry = 0
while retry < 10:
    try:
        redis.get('notify-keyspace-events')
        break
    except ConnectionError as e:
        retry += 1
        logging.warning("cannot connect to redis DB - retrying (%d)", retry)
        time.sleep(1)
assert retry < 10, "Cannot connect to redis DB - aborting"


def md5file(fp):
    """Returns the MD5 of the file fp."""
    m = hashlib.md5()
    with open(fp, 'rb') as f:
        for l in f.readlines():
            m.update(l)
    return m.hexdigest()
예제 #3
0
redis = RedisDatabase(app.iniconfig.get('redis', 'host'),
                      app.iniconfig.get('redis', 'port', fallback=6379),
                      app.iniconfig.get('redis', 'db', fallback=0),
                      app.iniconfig.get('redis', 'password', fallback=None))

assert app.iniconfig.get(
    'default', 'taskfile_dir'), "missing taskfile_dir from settings.ini"
taskfile_dir = app.iniconfig.get('default', 'taskfile_dir')
assert os.path.isdir(
    taskfile_dir), "taskfile_dir (%s) must be a directory" % taskfile_dir

retry = 0
while retry < 10:
    try:
        storages_list = redis.get("admin:storages")
        assert storages_list, "ERROR: cannot get storages from worker db"
        break
    except (ConnectionError, AssertionError) as e:
        retry += 1
        time.sleep(1)

assert retry < 10, "Cannot connect to redis DB - aborting"


def append_version(v):
    global VERSION
    VERSION += ":" + v


def get_version():