def __init__(self):
     self.config = Config()
     self.redlock = get_redlock_factory(self.config)
     self.reddit = get_reddit_instance(self.config)
     self.reddit_manager = RedditManager(self.reddit)
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging(config=self.config)
     notification_svc = NotificationService(self.config)
     self.response_handler = ResponseHandler(
         self.reddit_manager,
         self.uowm,
         self.event_logger,
         source='summons',
         live_response=self.config.live_responses,
         notification_svc=notification_svc)
     dup_image_svc = DuplicateImageService(self.uowm,
                                           self.event_logger,
                                           self.reddit,
                                           config=self.config)
     response_builder = ResponseBuilder(self.uowm)
     self.summons_handler = SummonsHandler(
         self.uowm,
         dup_image_svc,
         self.reddit_manager,
         response_builder,
         self.response_handler,
         event_logger=self.event_logger,
         summons_disabled=False,
         notification_svc=notification_svc)
Beispiel #2
0
 def __init__(self):
     self.config = Config()
     from redditrepostsleuth.core.services.duplicateimageservice import DuplicateImageService
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.notification_svc = NotificationService(self.config)
     self.event_logger = EventLogging()
     self.reddit = get_reddit_instance(self.config)
     self.dup_service = DuplicateImageService(self.uowm, self.event_logger,
                                              self.reddit)
Beispiel #3
0
 def __init__(self):
     self.config = Config()
     self.reddit = RedditManager(get_reddit_instance(self.config))
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging(config=self.config)
     self.response_handler = ResponseHandler(
         self.reddit,
         self.uowm,
         self.event_logger,
         live_response=self.config.live_responses)
Beispiel #4
0
 def __init__(self):
     self.config = Config()
     self.reddit = RedditManager(get_reddit_instance(self.config))
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging(config=self.config)
     self.response_handler = ResponseHandler(
         self.reddit,
         self.uowm,
         self.event_logger,
         live_response=self.config.live_responses)
     self.notification_svc = NotificationService(self.config)
     self.config_updater = SubredditConfigUpdater(
         self.uowm,
         self.reddit.reddit,
         self.response_handler,
         self.config,
         notification_svc=self.notification_svc)
 def __init__(self):
     self.config = Config()
     self.reddit = get_reddit_instance(self.config)
     self.reddit_manager = RedditManager(self.reddit)
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     event_logger = EventLogging(config=self.config)
     response_handler = ResponseHandler(
         self.reddit_manager,
         self.uowm,
         event_logger,
         source='submonitor',
         live_response=self.config.live_responses)
     dup_image_svc = DuplicateImageService(self.uowm,
                                           event_logger,
                                           self.reddit,
                                           config=self.config)
     response_builder = ResponseBuilder(self.uowm)
     self.sub_monitor = SubMonitor(dup_image_svc,
                                   self.uowm,
                                   self.reddit_manager,
                                   response_builder,
                                   response_handler,
                                   event_logger=event_logger,
                                   config=self.config)
Beispiel #6
0
from redditrepostsleuth.core.celery.response_tasks import process_monitored_sub
from redditrepostsleuth.core.logging import log
from redditrepostsleuth.core.services.eventlogging import EventLogging
from redditrepostsleuth.core.services.reddit_manager import RedditManager
from redditrepostsleuth.core.services.response_handler import ResponseHandler
from redditrepostsleuth.core.db.db_utils import get_db_engine
from redditrepostsleuth.core.db.uow.sqlalchemyunitofworkmanager import SqlAlchemyUnitOfWorkManager
from redditrepostsleuth.core.services.responsebuilder import ResponseBuilder

from redditrepostsleuth.core.util.helpers import get_reddit_instance, get_redis_client
from redditrepostsleuth.core.services.duplicateimageservice import DuplicateImageService
from redditrepostsleuth.submonitorsvc.submonitor import SubMonitor

if __name__ == '__main__':
    config = Config()
    event_logger = EventLogging(config=config)
    uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(config))
    response_builder = ResponseBuilder(uowm)
    reddit = get_reddit_instance(config)
    reddit_manager = RedditManager(reddit)
    dup = DuplicateImageService(uowm, event_logger, reddit, config=config)
    monitor = SubMonitor(dup,
                         uowm,
                         reddit_manager,
                         response_builder,
                         ResponseHandler(reddit_manager,
                                         uowm,
                                         event_logger,
                                         source='submonitor',
                                         live_response=config.live_responses),
                         event_logger=event_logger,
Beispiel #7
0
 def __init__(self):
     self.config = Config()
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging()
Beispiel #8
0
 def __init__(self):
     self.config = Config()
     self.event_logger = EventLogging(config=self.config)
import redis

sys.path.append('./')
from redditrepostsleuth.core.config import Config
from redditrepostsleuth.core.model.events.celerytask import CeleryQueueSize
from redditrepostsleuth.core.logging import log
from redditrepostsleuth.core.services.eventlogging import EventLogging

config = Config()

def log_queue_size(event_logger):
    skip_keys = ['unacked_index', 'unacked_mutex', 'unacked']
    while True:
        try:
            client = redis.Redis(host=config.redis_host, port=config.redis_port, db=0, password=config.redis_password)

            for queue in client.scan_iter():
                queue_name = queue.decode('utf-8')
                if queue_name[0:1] == '_' or len(queue_name) > 20 or queue_name in skip_keys:
                    continue
                event_logger.save_event(
                    CeleryQueueSize(queue_name, client.llen(queue_name), event_type='queue_update'))
            time.sleep(2)
        except Exception as e:
            pass
            # log.error('Queue update task failed. Key %s', queue_name)

if __name__ == '__main__':
    log.info('Starting Monitor Service')
    log_queue_size(EventLogging())