Ejemplo n.º 1
0
 def handle(self, *filenames, **options):
     if not filenames:
         filenames = [get_controller_root(), '.']
     warnings = checkPaths(filenames)
     for warning in warnings:
         print warning
     if warnings:
         print 'Total warnings: %d' % len(warnings)
         raise SystemExit(1)
Ejemplo n.º 2
0
 def handle(self, *args, **options):
     if options.get('username'):
         warnings.warn('"username" has been deprecated in favor of "user"', DeprecationWarning)
     if options.get('user') and options.get('username'):
         raise CommandError("Only one of this options should be provided: --user OR --username")
     
     user = options.get('user') or options.get('username') or 'confine'
     context = {'site_root': get_site_root(),
                'user': user,
                'group': options.get('group') or user,
                'bin_path': path.join(get_controller_root(), 'bin'),
                'processes': options.get('processes'),
                'greenlets': options.get('greenlets') }
     
     celery_config = (
         '# Name of nodes to start, here we have a single node\n'
         'CELERYD_NODES="w1 w2"\n'
         '\n'
         '# Where to chdir at start.\n'
         'CELERYD_CHDIR="%(site_root)s"\n'
         '\n'
         '# How to call "manage.py celeryd_multi"\n'
         'CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"\n'
         '\n'
         '# Extra arguments to celeryd\n'
         'CELERYD_OPTS="-P:w1 processes -c:w1 %(processes)s -Q:w1 celery \\\n'
         '              -P:w2 gevent -c:w2 %(greenlets)s -Q:w2 gevent --time-limit=300"\n'
         '\n'
         '# Name of the celery config module.\n'
         'CELERY_CONFIG_MODULE="celeryconfig"\n'
         '\n'
         '# %%n will be replaced with the nodename.\n'
         'CELERYD_LOG_FILE="/var/log/celery/%%n.log"\n'
         'CELERYD_PID_FILE="/var/run/celery/%%n.pid"\n'
         'CELERY_CREATE_DIRS=1\n'
         '\n'
         '# Full path to the celeryd logfile.\n'
         'CELERYEV_LOG_FILE="/var/log/celery/celeryev.log"\n'
         'CELERYEV_PID_FILE="/var/run/celery/celeryev.pid"\n'
         '\n'
         '# Workers should run as an unprivileged user.\n'
         'CELERYD_USER="******"\n'
         'CELERYD_GROUP="%(group)s"\n'
         '\n'
         '# Persistent revokes\n'
         'CELERYD_STATE_DB="$CELERYD_CHDIR/persistent_revokes"\n'
         '\n'
         '# Celeryev\n'
         'CELERYEV="$CELERYD_CHDIR/manage.py"\n'
         'CELERYEV_CAM="djcelery.snapshot.Camera"\n'
         'CELERYEV_USER="******"\n'
         'CELERYEV_GROUP="$CELERYD_GROUP"\n'
         'CELERYEV_OPTS="celeryev"\n'
         '\n'
         '# Celerybeat\n'
         'CELERYBEAT="${CELERYD_CHDIR}/manage.py celerybeat"\n'
         'CELERYBEAT_USER="******"\n'
         'CELERYBEAT_GROUP="$CELERYD_GROUP"\n'
         'CELERYBEAT_CHDIR="$CELERYD_CHDIR"\n'
         'CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"\n' % context)
     
     run("echo '%s' > /etc/default/celeryd" % celery_config)
     
     # https://raw.github.com/celery/celery/master/extra/generic-init.d/
     for script in ['celeryevcam', 'celeryd', 'celerybeat']:
         context['script'] = script
         run('cp %(bin_path)s/%(script)s /etc/init.d/%(script)s' % context)
         run('chmod +x /etc/init.d/%(script)s' % context)
         run('update-rc.d %(script)s defaults' % context)
     
     rotate = ('/var/log/celery/*.log {\n'
               '    weekly\n'
               '    missingok\n'
               '    rotate 10\n'
               '    compress\n'
               '    delaycompress\n'
               '    notifempty\n'
               '    copytruncate\n'
               '}')
     run("echo '%s' > /etc/logrotate.d/celeryd" % rotate)
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        if options.get('username'):
            warnings.warn('"username" has been deprecated in favor of "user"',
                          DeprecationWarning)
        if options.get('user') and options.get('username'):
            raise CommandError(
                "Only one of this options should be provided: --user OR --username"
            )

        user = options.get('user') or options.get('username') or 'confine'
        context = {
            'site_root': get_site_root(),
            'user': user,
            'group': options.get('group') or user,
            'bin_path': path.join(get_controller_root(), 'bin'),
            'processes': options.get('processes'),
            'greenlets': options.get('greenlets')
        }

        celery_config = (
            '# Name of nodes to start, here we have a single node\n'
            'CELERYD_NODES="w1 w2"\n'
            '\n'
            '# Where to chdir at start.\n'
            'CELERYD_CHDIR="%(site_root)s"\n'
            '\n'
            '# How to call "manage.py celeryd_multi"\n'
            'CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"\n'
            '\n'
            '# Extra arguments to celeryd\n'
            'CELERYD_OPTS="-P:w1 processes -c:w1 %(processes)s -Q:w1 celery \\\n'
            '              -P:w2 gevent -c:w2 %(greenlets)s -Q:w2 gevent --time-limit=300"\n'
            '\n'
            '# Name of the celery config module.\n'
            'CELERY_CONFIG_MODULE="celeryconfig"\n'
            '\n'
            '# %%n will be replaced with the nodename.\n'
            'CELERYD_LOG_FILE="/var/log/celery/%%n.log"\n'
            'CELERYD_PID_FILE="/var/run/celery/%%n.pid"\n'
            'CELERY_CREATE_DIRS=1\n'
            '\n'
            '# Full path to the celeryd logfile.\n'
            'CELERYEV_LOG_FILE="/var/log/celery/celeryev.log"\n'
            'CELERYEV_PID_FILE="/var/run/celery/celeryev.pid"\n'
            '\n'
            '# Workers should run as an unprivileged user.\n'
            'CELERYD_USER="******"\n'
            'CELERYD_GROUP="%(group)s"\n'
            '\n'
            '# Persistent revokes\n'
            'CELERYD_STATE_DB="$CELERYD_CHDIR/persistent_revokes"\n'
            '\n'
            '# Celeryev\n'
            'CELERYEV="$CELERYD_CHDIR/manage.py"\n'
            'CELERYEV_CAM="djcelery.snapshot.Camera"\n'
            'CELERYEV_USER="******"\n'
            'CELERYEV_GROUP="$CELERYD_GROUP"\n'
            'CELERYEV_OPTS="celeryev"\n'
            '\n'
            '# Celerybeat\n'
            'CELERYBEAT="${CELERYD_CHDIR}/manage.py celerybeat"\n'
            'CELERYBEAT_USER="******"\n'
            'CELERYBEAT_GROUP="$CELERYD_GROUP"\n'
            'CELERYBEAT_CHDIR="$CELERYD_CHDIR"\n'
            'CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"\n' %
            context)

        run("echo '%s' > /etc/default/celeryd" % celery_config)

        # https://raw.github.com/celery/celery/master/extra/generic-init.d/
        for script in ['celeryevcam', 'celeryd', 'celerybeat']:
            context['script'] = script
            run('cp %(bin_path)s/%(script)s /etc/init.d/%(script)s' % context)
            run('chmod +x /etc/init.d/%(script)s' % context)
            run('update-rc.d %(script)s defaults' % context)

        rotate = ('/var/log/celery/*.log {\n'
                  '    weekly\n'
                  '    missingok\n'
                  '    rotate 10\n'
                  '    compress\n'
                  '    delaycompress\n'
                  '    notifempty\n'
                  '    copytruncate\n'
                  '}')
        run("echo '%s' > /etc/logrotate.d/celeryd" % rotate)