This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/workers/gcworker.py
2015-12-16 15:45:02 -05:00

28 lines
971 B
Python

import logging
from app import app
from data.model.repository import find_repository_with_garbage, garbage_collect_repo
from workers.worker import Worker
logger = logging.getLogger(__name__)
class GarbageCollectionWorker(Worker):
def __init__(self):
super(GarbageCollectionWorker, self).__init__()
self.add_operation(self._garbage_collection_repos,
app.config.get('GARBAGE_COLLECTION_FREQUENCY', 30))
def _garbage_collection_repos(self):
""" Performs garbage collection on repositories. """
repository = find_repository_with_garbage()
if repository is None:
logger.debug('No repository with garbage found')
return
logger.debug('Starting GC of repository #%s (%s)', repository.id, repository.name)
garbage_collect_repo(repository)
logger.debug('Finished GC of repository #%s (%s)', repository.id, repository.name)
if __name__ == "__main__":
worker = GarbageCollectionWorker()
worker.start()