geosolutions-it / gfdrr-det

Data Exploration Tool
https://waffle.io/geosolutions-it/gfdrr-det
GNU General Public License v3.0
3 stars 0 forks source link

Implementing deletion of expired items from the filesystem #104

Closed ricardogsilva closed 6 years ago

ricardogsilva commented 6 years ago

This PR is connected to #86

It implements a strategy for cleaning stale files from the filesystem.

Implementation just uses the django-oseoserver hook for cleaning items. oseoserver features the oseoserver.tasks.clean_expired_items function, which is a celery task. This task calls the OrderItem.expire method which in turn calls in a customizable clean_item method that can be attached to an ItemProcessor class.

In this PR we implement the gfdrr_det.orderprocessors.HeveOrderProcessor.clean_item method. It basically checks if the file served by a specific URL is still being used by any available order item and deletes the file if it is not being used.

The oseoserver task that deals with order item expiry is not enabled by default and must be configured to run manually. This PR sets up a celery beat schedule for running the task everyday at 01:00.

Finally this PR sets also a couple other celery settings, most notably it sets CELERY_TASK_ALWAYS_EAGER = True in order to enable parallelization of tasks.

Note

In order to activate the celery beat schedule it is necessary to configure the server appropriately, as specified in

http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#starting-the-scheduler

This step shall be done after the PR is merged.