Пример #1
0
def main(argv):
    logutil.initialize()

    import src.common.configutil as configutil

    configutil.initialize("^env((?!mydas).)*\.conf$")

    import src.core.redisutil as redisutil
    import src.core.tornadoutil as tornadoutil
    import src.common.queueutil as queueutil
    import src.trigger.trigger as trigger

    print argv

    try:
        opts, args = getopt.getopt(argv,"hr:",["Public host="])
    except getopt.GetoptError:
        usage()
    servc_host = ""
    for opt, arg in opts:
        if opt in ("-r", "--public_host"):
            _config = get_config()
            servc_host = arg
            servc_port = _config.tornado.port
            _config.OAuth2_redirect_uri_host = ("http://%s:%d/v1" % (servc_host, 
                                                                     servc_port))
        else:
            usage()

    redisutil.initialize()
    queueutil.initialize()
    trigger.initialize()

    queueutil.start()
    trigger.start()    
    tornadoutil.start()
Пример #2
0
@author: Kevin Chien
'''
import inspect
from functools import wraps

from tornado.gen import coroutine, Return

from src.common.logutil import get_logger
from src.common.configutil import get_config
from src.core.redisutil import get_redis_client
from src.common.jsonutil import dict2json, json2dict
from src.common.systemutil import get_timestamp

ROOT_PREFIX = 'cache'
_logger = get_logger(__name__)
_config = get_config()

def cache(prefix = None, key = None, expires_in = 3600):
    """
    A decorator to cache data. 
    
    @param prefix: A prefix or namespace in Redis. If the argument is not given, function name will be used.
    @type prefix: C{string}
    @param key: The key to be used in Redis. If the argument is not given, all the arguments will be appended to generate the key.
    @type key: C{string}
    @param expires_in: How long the cached data expire. If the argument is string, it will be resolved by configutil. Otherwise, it will be used directly. 
    @type expires_in: C{int}
    """
    def _decorator(func):
        @coroutine
        @wraps(func)