示例#1
0
redis_db_without_decode = 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), False)

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:
        current_default_config = redis_db.exists("default") \
                                 and redis_db.hget("default", "configuration")
        break
    except (ConnectionError, AssertionError) as e:
        retry += 1
        time.sleep(1)

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

if current_default_config != default_config:
    redis_db.hset("default", "configuration", default_config)
    redis_db.hset("default", "timestamp", time.time())


def append_version(v):
    global VERSION
示例#2
0
app.logger.setLevel(logging.getLevelName(
                    app.iniconfig.get('default', 'log_level', fallback='ERROR')))

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:
        current_default_config = redis.exists("default") and redis.hget("default", "configuration")
        break
    except (ConnectionError, AssertionError) as e:
        retry += 1
        time.sleep(1)

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

if current_default_config != default_config:
    redis.hset("default", "configuration", default_config)
    redis.hset("default", "timestamp", time.time())


def append_version(v):
    global VERSION
    VERSION += ":" + v
示例#3
0
    print("[%s] ** launching: %s - log %s" % (service, cmdline, logfile))
    sys.stdout.flush()
    p1 = subprocess.Popen(worker_arg, stdout=log_fh, stderr=subprocess.STDOUT, close_fds=True)
    current_pid = p1.pid
    print("[%s] ** launched with pid: %d" % (service, p1.pid))
    sys.stdout.flush()

    try:
        while True:
            poll = p1.poll()
            if poll is not None:
                break
            time.sleep(5)
            if time.time() - start > 30:
                # check if worker still there
                w = redis.exists("admin:worker:%s:%d" % (service, p1.pid))
                if not w:
                    print("[%s-%d] ** No heartbeat" % (service, p1.pid))
                    p1.terminate()
    except Exception as e:
        log_fh.write("-" * 80)
        log_fh.write("\n")
        log_fh.write("INTERRUPTED: "+str(e))
        log_fh.write("\n")

    # whatever happened, we remove trace of the worker
    redis.delete("admin:worker:%s:%d" % (service, p1.pid))

    stop = time.time()

    print("[%s] ** process stopped: %d" % (service, p1.pid))
示例#4
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:
        current_default_config = redis.exists("default") and redis.hget(
            "default", "configuration")
        break
    except (ConnectionError, AssertionError) as e:
        retry += 1
        time.sleep(1)

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

if current_default_config != default_config:
    redis.hset("default", "configuration", default_config)
    redis.hset("default", "timestamp", time.time())


def append_version(v):
    global VERSION