==========
.. image:: https://api.travis-ci.org/LPgenerator/django-mmc.png?branch=master
:alt: Build Status
:target: https://travis-ci.org/LPgenerator/django-mmc
.. image:: https://landscape.io/github/LPgenerator/django-mmc/master/landscape.svg
:target: https://landscape.io/github/LPgenerator/django-mmc/master
:alt: Code Health
.. image:: https://img.shields.io/badge/python-2.6,2.7,3.4,3.5,pypy,pypy3-blue.svg
:alt: Python 2.6, 2.7, 3.4
:target: https://pypi.python.org/pypi/django-mmc/
.. image:: https://img.shields.io/pypi/v/django-mmc.svg
:alt: Current version on PyPi
:target: https://crate.io/packages/django-mmc/
.. image:: https://img.shields.io/pypi/dm/django-mmc.svg
:alt: Downloads from PyPi
:target: https://crate.io/packages/django-mmc/
.. image:: https://img.shields.io/badge/license-GPLv2-green.svg
:target: https://pypi.python.org/pypi/django-mmc/
:alt: License
What's that
-----------
App for monitoring management commands on Django.
Quick installation
------------------
1. Using pip:
.. code-block:: bash
$ pip install django-mmc
2. Add ``mmc`` application to ``INSTALLED_APPS`` in your settings file
3. Inject management classes before apps will be loaded
.. code-block:: python
from mmc.mixins import inject_management
inject_management()
4. Sync database (``./manage.py syncdb`` or ``./manage.py migrate``)
5. Enjoy
Demo installation
-----------------
**Docker**
.. code-block:: bash
$ git clone --depth 1 -b master https://github.com/LPgenerator/django-mmc.git mmc
$ cd mmc
$ docker build -t mmc .
$ docker run -it -d -p 8000:8000 --name mmc mmc
$ docker exec -i -t mmc /bin/bash
$ cd /mmc_demo/
**Vagrant**
.. code-block:: bash
$ git clone --depth 1 -b master https://github.com/LPgenerator/django-mmc.git mmc
$ cd mmc
$ vagrant up --provider virtualbox
$ vagrant ssh
$ cd /mmc_demo/
**OS X/Linux**
.. code-block:: bash
$ sudo apt-get install -y virtualenvwrapper || brew install pyenv-virtualenvwrapper
$ source /usr/share/virtualenvwrapper/virtualenvwrapper.sh || source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv django-mmc
$ git clone --depth 1 https://github.com/LPgenerator/django-mmc.git
$ cd django-mmc
$ python setup.py develop
$ cd demo
$ pip install -r ../requirements/dev.txt
$ python manage.py syncdb --noinput
$ python manage.py createsuperuser --username admin --email admin@local.host
$ python manage.py test_command >& /dev/null
$ python manage.py test_command_noargs >& /dev/null
$ python manage.py test_command_error >& /dev/null
$ python manage.py test_command_killed >& /dev/null
$ python manage.py runserver >& /dev/null &
Open app in browser (login and password is admin/admin):
.. code-block:: bash
$ xdg-open http://127.0.0.1:8000/admin/mmc/mmclog/ >& /dev/null || open http://127.0.0.1:8000/admin/mmc/mmclog/ >& /dev/null
Configuration
-------------
1. Execute the command, and script will be available at http://127.0.0.1:8000/admin/mmc/mmcscript/
2. Configure script options on script settings http://127.0.0.1:8000/admin/mmc/mmcscript/1/
3. Add email addresses for errors notification http://127.0.0.1:8000/admin/mmc/mmcemail/
4. All logs available on Logs page http://127.0.0.1:8000/admin/mmc/mmclog/
5. If you are using sentry, configure sentry, and all errors will be send into sentry too
Usage without inject
--------------------
If you want track only specified commands manually without auto-inject,
follow to examples below:
.. code-block:: python
# args
from mmc.mixins import BaseCommand
class Command(BaseCommand):
def handle(self, *args, **options):
print "OK"
# noargs
from mmc.mixins import NoArgsCommand
class Command(NoArgsCommand):
def handle_noargs(self, *args, **options):
print "OK"
When you are using auto-inject, you can use ignore flag on Scripts/Hosts settings.
Logs about execution not be stored, but if you got any error on your commands,
you will be notified to emails.
Cron debug
----------
For debug any messages or some errors on app, run commands with example below:
.. code-block:: bash
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
MAILTO=root@localhost
PYTHON_BIN=/home/user/example.com/venv/bin/python
MANAGE_PY=/home/user/example.com/www/manage.py
LOG_FILE=/var/log/mmc.cron.log
# Project commands
50 2 * * * $PYTHON_BIN $MANAGE_PY clean >> $LOG_FILE 2>&1
Multi-instance lock
-------------------
If you are using "One copy" functionality, and command is run on multiple
servers, you can use Memcached/Redis lock. Just configure it on settings.py:
.. code-block:: python
MMC_LOCK_TYPE = 'MemcacheLock'
MMC_MEMCACHED_CONFIG = {
'servers': ['127.0.0.1:11211'], 'debug': 0
}
Management commands
-------------------
``mmc_cleanup`` - clean logs by days/date
``mmc_notify`` - notify users, when script is killed by OS (that actual for long tasks and for big databases).
For detailed check (by pid and name) you can install ``psutil``.
Sentry support
--------------
If you want receive notifications and detailed traceback to Sentry,
you can install ``raven``, and configure project dsn settings.
Publications
------------
* `Установка и использование с примерами на русском <http://habrahabr.ru/post/223151/>`_.
* `Completely installation and usage with examples. Translated by Google <http://translate.google.com/translate?hl=en&sl=ru&tl=en&u=http://habrahabr.ru/post/223151/>`_.
Screenshots
-----------
.. image:: /screenshots/log_changelist.jpg
.. image:: /screenshots/log_edit.jpg
.. image:: /screenshots/script_changelist.jpg
.. image:: /screenshots/script_edit.jpg
.. image:: /screenshots/email_changelist.jpg
.. image:: /screenshots/email_edit.jpg
.. image:: /screenshots/hosts_changelist.jpg
Compatibility:
-------------
* Python: 2.6, 2.7, 3.4, 3.5, pypy, pypy3
* Django: 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9
Metadata
Release files for django-mmc 1.6.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-mmc-1.6.5.tar.gz | 30.9 kB | Without provenance | Details for django-mmc-1.6.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_mmc-1.6.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_mmc-1.6.5-py2.py3-none-any.whl |
Total release size: 88.4 kB
Release files / django-mmc-1.6.5.tar.gz
| Download URL | django-mmc-1.6.5.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
503771363d63eb6db9b3518cc44e974209d48d1c4c9e248ce4e22c5a6fbc89dc
|
|
BLAKE2b-256 checksum How to use checksums |
76f2aa475a4b59e84c08ada47e3c2f92396eb31232f6a3371f0975d47041bc4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_mmc-1.6.5-py2.py3-none-any.whl
| Download URL | django_mmc-1.6.5-py2.py3-none-any.whl |
|---|---|
| Size | 57.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6f3d0946bb66e01683e7d93ee9977092a60ddfd7b1d288e8eb30d5c59cbab78c
|
|
BLAKE2b-256 checksum How to use checksums |
a4b6534b4f65b151ad3089b0034c192b7cf1b101abf614d4f948bce3d8158514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-mmc 1.6.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.