19 lines
669 B
Python
19 lines
669 B
Python
from app import app
|
|
from data.database import UseThenDisconnect
|
|
from workers.gcworker.models_pre_oci import pre_oci_model as model
|
|
from workers.worker import Worker
|
|
|
|
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. """
|
|
with UseThenDisconnect(app.config):
|
|
model.perform_garbage_collection()
|
|
|
|
if __name__ == "__main__":
|
|
worker = GarbageCollectionWorker()
|
|
worker.start()
|