A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/LPgenerator/django-mmc below:

LPgenerator/django-mmc: App for monitoring management commands on Django.

App for monitoring management commands on Django.

  1. Using pip:
  1. Add mmc application to INSTALLED_APPS in your settings file
  2. Inject management classes before apps will be loaded
from mmc.mixins import inject_management

inject_management()
  1. Sync database (./manage.py syncdb or ./manage.py migrate)
  2. Enjoy

Docker

$ 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

$ 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

$ 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):

$ 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
  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

If you want track only specified commands manually without auto-inject, follow to examples below:

# 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.

For debug any messages or some errors on app, run commands with example below:

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

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:

MMC_LOCK_TYPE = 'MemcacheLock'

MMC_MEMCACHED_CONFIG = {
    'servers': ['127.0.0.1:11211'], 'debug': 0
}

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.

If you want receive notifications and detailed traceback to Sentry, you can install raven, and configure project dsn settings.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4