Metadata-Version: 2.1
Name: django-uwsgi-taskmanager
Version: 1.0.1
Summary: Django application to manage async tasks via admin interface, using uWSGI spooler.
Home-page: https://github.com/openpolis/django-uwsgi-taskmanager.git
Author: Gabriele Giaccari, Gabriele Lucci, Guglielmo Celata, Paolo Melchiorre
Author-email: info@openpolis.it
License: AGPLv3 License
Project-URL: Bug Reports, https://github.com/openpolis/django-uwsgi-taskmanager/issues
Project-URL: Source Code, https://github.com/openpolis/django-uwsgi-taskmanager
Keywords: async,cron,django,manager,spooler,task,timer,uwsgi
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: ~=3.6
Description-Content-Type: text/markdown
Requires-Dist: django (>=1.11)
Requires-Dist: file-read-backwards (>=2.0.0)
Requires-Dist: uwsgidecorators-fallback (>=0.0.3)
Requires-Dist: uwsgidecorators (>=1.1.0)

# Django uWSGI Taskmanager

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)

Django application to manage async tasks via admin interface, using uWSGI spooler.

## Features

- Start and stop your tasks via admin
- Schedule tasks
- Plan tasks as cron items
- Check or download the generated reports/logs
- Simply write a standard Django Command class (your app doesn't need to interact with Django uWSGI Taskmanager)

## Installation

0.  Pip install the app:

    -  via pypi:

       `pip install django-uwsgi-taskmanager`

    -  or via github:

       `pip install git+https://github.com/openpolis/django-uwsgi-taskmanager.git`

1.  Add "taskmanager" to your `INSTALLED_APPS` setting like this:

    ```python
    INSTALLED_APPS = [
        "django.contrib.admin",
        # ...
        "taskmanager",
    ]
    ```

2. Run `python manage.py migrate` to create the taskmanager tables.

3. Run `python manage.py collectcommands` to create taskmanager commands.

4. Include the taskmanager URLconf in your project `urls.py` like this _(optional)_:

    ```python
    from django.contrib import admin
    from django.urls import include, path

    urlpatterns = [
        path("admin/", admin.site.urls),
        path("taskmanager/", include("taskmanager.urls")),
    ]
    ```

5. Set parameters in your settings file as below _(optional)_:

    ```
    TASK_MANAGER_N_LINES_IN_REPORT_INLINE = 10
    TASK_MANAGER_N_REPORTS_INLINE = 3
    TASK_MANAGER_SHOW_LOGVIEWER_LINK = True
    TASK_MANAGER_USE_FILTER_COLLAPSE = True
    TASK_MANAGER_SAVE_LOGFILE = False
    ```

## Usage

You just need to install `django-uwsgi-taskmanager` in your Django Project and run `collectcommands` as described.
Django uWSGI Taskmanager will collect all the commands and make them available for asynchronous scheduling in the admin.

If you need a new asynchronous task, just write a standard custom Django command, and synchronize the app. Then go to the admin page and schedule it.

You can disable some commands from the admin, and let users (with limited permissions) schedule only the available ones.

uWSGI ini file (vassal) has to include the [spooler](https://uwsgi-docs.readthedocs.io/en/latest/Spooler.html) and [pythonpath](https://uwsgi-docs.readthedocs.io/en/latest/PythonDecorators.html) option.

> **NOTE**: remember to manually create the `spooler` directory with right permissions before start uWSGI

### Demo

This a basic Django demo project with a `uwsgi.ini` file and four directories (`media`, `spooler`, `static`, `venv`).

```bash
demo/
├── demo/
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
├── media/
├── spooler/
├── static/
├── uwsgi.ini
└── venv/
```

This is the content of `uwsgi.ini` file required to execute the project with Django:

```ini
[uwsgi]
chdir = %d
env = DJANGO_SETTINGS_MODULE=demo.settings
http-socket = :8000
master = true
module = demo.wsgi
plugin = python3
pythonpath = %d
spooler = %dspooler
static-map = /static/=%dstatic
virtualenv = %dvenv
```

#### Try the demo project

Enter the demo directory, then create and activate the demo virtual environments:

```bash
$ cd demo
$ mkdir -p venv
$ python3 -m venv ./venv
$ source ./venv/bin/activate
```

Install Django uWSGI taskmanager:

```bash
(venv) $ pip install django-uwsgi-taskmanager
```

Install uWSGI (if you use uWSGI of your OS you can skip this step):

```bash
(venv) $ pip install uwsgi
```

Collect all static files:

```bash
(venv) $ python manage.py collectstatic
```

Create all the tables:

```bash
(venv) $ python manage.py migrate
```

Collect all commands:

```bash
(venv) $ python manage.py collectcommands
```

Create a super user to login the admin:

```bash
(venv) $ python manage.py createsuperuser
```

Start the project with uWSGI:

```bash
(venv) $ uwsgi --ini uwsgi.ini
```

Visit http://127.0.0.1:8000/admin/

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.1] - 2019-07-13

### Changed

- Rename `collect_commands` to `collectcommands`
- Add missings setps in `README.md`

### Fixed

- Fix version 1.0.0 release date in `CHANGELOG.md`
- Add missing `__init__.py` in migrations directory
- Add missing `STATIC_ROOT` in demo settings
- Add missing media directory and settings
- Fix convert to local datetime function
- Update and complete `setup.py`

## [1.0.0] - 2019-07-12

### Added

- First release

[Unreleased]: https://github.com/openpolis/django-uwsgi-taskmanager/compare/v1.0.1...master
[1.0.1]: https://github.com/openpolis/django-uwsgi-taskmanager/releases/v1.0.0...v1.0.1
[1.0.0]: https://github.com/openpolis/django-uwsgi-taskmanager/releases/tag/v1.0.0

# Authors

* Gabriele Giaccari ([@gabbork](https://github.com/gabbork))
* Gabriele Lucci ([@gabrielelucci](https://github.com/gabrielelucci))
* Guglielmo Celata ([@guglielmo](https://github.com/guglielmo))
* Paolo Melchiorre ([@pauloxnet](https://github.com/pauloxnet))

# License

**Django uWSGI taskmanager** is an application to manage async tasks via admin interface, using uWSGI spooler.

Copyright (C) 2019  Gabriele Giaccari, Gabriele Lucci, Guglielmo Celata, Paolo Melchiorre

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.


