Пример #1
0
def index():
    if check_redis():
        redis = True
    else:
        redis = False
        flash('Cache is offline, percentage complete may be incorrect, please contact support.', 'warning')
    page = int(request.args.get('page', 1))
    pagination = Dispatcher.find_all_desc().paginate(page=page, per_page=20)
    return render_template('dispatcher/index.html', pagination=pagination, redis=redis)
Пример #2
0
def vib(hash_id):
    redis.incr('vib_counter')
    redis_result = redis.get(hash_id)
    if redis_result:
        return redis_result
    send = Send.find_by_hash(hash_id)
    if send:
        data = send.message
        response = data['html']
        if response:
            soup = BeautifulSoup(response)
            if soup.find('span', 'preheader'):
                soup.find('span', 'preheader').extract()
                response = unicode(soup)

            if check_redis():
                set_cache(hash_id, response, 86400)  # 1 day
            return response
    abort(404)
Пример #3
0
def admin_index():
    redis_status = check_redis()
    default = get_count('default')
    mail = get_count('mail')
    beat = get_count('beat')
    dispatcher = get_count('dispatcher')
    vib_counter = get_cache('vib_counter')
    beat_retry_failues = get_cache('beat_retry_failues')
    beat_send_scheduled = get_cache('beat_send_scheduled')
    lock_violation_send_scheduled = get_cache('lock_violation_send_scheduled')
    lock_violation_retry_failures = get_cache('lock_violation_retry_failures')

    return render_template(
        'admin/index.html',
        default=default,
        mail=mail,
        dispatcher=dispatcher,
        redis_status=redis_status,
        beat=beat,
        vib_counter=vib_counter,
        beat_retry_failues=beat_retry_failues,
        lock_violation_send_scheduled=lock_violation_send_scheduled,
        beat_send_scheduled=beat_send_scheduled,
        lock_violation_retry_failures=lock_violation_retry_failures)
Пример #4
0
def status():
    """Check the database and cache, and report their status."""
    services = {}
    code = 200

    # DB
    if isinstance(Account.query.all(), list):
        services['db'] = 'ok'
    else:
        services['db'] = 'offline'
        code = 503

    # Cache. Offline is ok on dev. To test use SimpleCache instead of NullCache.
    redis.set('status-chck', 'a-ok')
    redis.expire('status-chck', 2)
    if redis.get('status-chck') == 'a-ok':
        services['cache'] = 'ok'
    else:
        services['cache'] = 'offline'
        code = 503
    services['status_code'] = code
    services['redis-online'] = check_redis()

    return jsonify(services), code
Пример #5
0
def dispatch(d_id):
    d = Dispatcher.find_by_id_anon(d_id)
    return render_template('admin/dispatch.html', d=d, r_up=check_redis())