예제 #1
0
def main(config):
    configureLogging(config)
    log = logging.getLogger('main')
    log.info('Starting conf_tracker version %s.', pkg_resources.require('conf_tracker')[0].version)
    if config.getboolean('daemon', 'daemon'):
        pidfile = config.get('daemon', 'pidfile')
        daemonize(pidfile)
        
    
    pw = config.get('host', 'password')
    h = config.get('host', 'host')
    p = config.get('host', 'port')
    
    #Setting up the DB connection
    log.info('Connecting to DB on: %s ' % (config.get('database', 'url')))

    if ("sqlite" in config.get('database', 'url')):
        engine = create_engine( config.get('database', 'url'), poolclass=NullPool )
        log.warning('You are using SQLite and we will use NullPool as pooling engine.')
    else:
        engine = create_engine( config.get('database', 'url'), pool_recycle=3600 )


    #meta.Session = sessionmaker( autoflush=False, autocommit=False, bind=engine)
    meta.Session.configure(bind=engine)
    
    con = connect(h, p, pw)
    conferences = {}
    while True:
        while not con.connected():
            log.warning("On main loop retrying...")
            con = connect(h, p, pw)
            
        e = con.recvEventTimed(5000)

        if e is None:
            continue

        conf_uuid = getUnquotedHeader(e, 'Conference-Unique-ID')
        action = getUnquotedHeader(e, 'Action')
        conf_size = getUnquotedHeader(e, 'Conference-Size')
        
        if action == 'stop-recording':
            try:
                TrackerConference.stop_recording(e, config)
                continue
            except Exception, e:
                log.exception('An error has occurred while executing stop-recording!')
                continue
        
        if conf_uuid not in conferences.keys():
            try:
                conf = TrackerConference(e, config)
                conferences[conf_uuid] = conf
            except Exception, e:
                log.exception('An error occured creating a new conference object! Continuing...')
                continue
예제 #2
0
def main(config):
            
    configureLogging(config)
    log = logging.getLogger('main')
    
    if config.getboolean('daemon', 'daemon'):
        pidfile = config.get('daemon', 'pidfile')
        daemonize(pidfile)
        
    
    pw = config.get('host', 'password')
    h = config.get('host', 'host')
    p = config.get('host', 'port')
    
    #Setting up the DB connection
    log.info('Connecting to DB on: %s ' % (config.get('database', 'url')))

    if ("sqlite" in config.get('database', 'url')):
        engine = create_engine( config.get('database', 'url'), poolclass=NullPool )
        log.warning('You are using SQLite and we will use NullPool as pooling engine.')
    else:
        engine = create_engine( config.get('database', 'url'), pool_recycle=3600 )


    Session = sessionmaker( autoflush=False, autocommit=False, bind=engine)
    
    log.info('Connecting to: %s:%s ' % (h, p))
    con = ESLconnection(h, p, pw)
    con.events('plain', 'CUSTOM conference::maintenance')
    conferences = {}
    while con.connected():
        e = con.recvEvent()

        if e is None:
            continue
            

        conf_uuid = getUnquotedHeader(e, 'Conference-Unique-ID')
        action = getUnquotedHeader(e, 'Action')
        conf_size = getUnquotedHeader(e, 'Conference-Size')
        
        if action == 'stop-recording':
            try:
                TrackerConference.stop_recording(e, config, Session())
                continue
            except Exception, e:
                log.critical('An error has occurred while executing stop-recording!\n%s' % traceback.format_exc())
                continue
        
        if conf_uuid not in conferences.keys():
            try:
                conf = TrackerConference(e, config, Session())
                conferences[conf_uuid] = conf
            except Exception, e:
                log.warning('An error occured creating a new conference object! Continuing... \n%s' % e)
                continue