#!/usr/bin/env python

from ptero_common.janitors.rabbitmq_janitor import RabbitMQJanitor
from ptero_common.janitors.postgres_janitor import PostgresJanitor
from ptero_common.janitors import perform_cleanup
import os


if __name__ == '__main__':
    perform_cleanup(janitor_spec={
        'postgres': {
            'required_envvars': ['PTERO_WORKFLOW_DB_STRING'],
            'cleanup_action': lambda: PostgresJanitor(
                os.environ['PTERO_WORKFLOW_DB_STRING']).clean(),
            },
        'rabbitmq': {
            'required_envvars': ['PTERO_WORKFLOW_CELERY_BROKER_URL'],
            'cleanup_action': lambda: RabbitMQJanitor(
                os.environ['PTERO_WORKFLOW_CELERY_BROKER_URL']).clean(),
            },
        })
