<commit_before>import shlex
import subprocess

from optparse import make_option

from django.core.management.base import BaseCommand
from django.utils import autoreload

# thanks to https://medium.com/aubergine-solutions/auto-reload-development-mode-for-celery-worker-using-docker-compose-and-django-management-2ba8e313eb37


def restart_celery(*args, **kwargs):
    kwargs = kwargs['kwargs']
    kill_worker_cmd = 'pkill -9 celery'
    subprocess.call(shlex.split(kill_worker_cmd))
    start_worker_cmd = 'celery -A worker worker --loglevel=%s --logfile=%s --uid=%s --gid=%s' % (kwargs['loglevel'], kwargs['logfile'], kwargs['uid'], kwargs['gid'])
    subprocess.call(shlex.split(start_worker_cmd))


class Command(BaseCommand):

    def add_arguments(self, parser):
        parser.add_argument('-lf', '--logfile',
            dest='logfile',
            help='define the logfile')

        parser.add_argument('-ll', '--loglevel',
            dest='loglevel',
            help='define the loglevel')

        parser.add_argument('-u', '--uid',
            dest='uid',
            help='define worker uid')

        parser.add_argument('-g', '--gid',
            dest='gid',
            help='define worker gid')
            

    def handle(self, *args, **options):
        self.stdout.write('Starting celery worker with autoreload...')
        kwargs = {
                'loglevel': options.get('loglevel'),
                'logfile': options.get('logfile'),
                'uid': options.get('uid'),
                'gid': options.get('gid'),
            }
        autoreload.run_with_reloader(restart_celery, args=None, kwargs=kwargs)<commit_msg>[server] fix celery worker args description<commit_after>import shlex
import subprocess

from optparse import make_option

from django.core.management.base import BaseCommand
from django.utils import autoreload

# thanks to https://medium.com/aubergine-solutions/auto-reload-development-mode-for-celery-worker-using-docker-compose-and-django-management-2ba8e313eb37


def restart_celery(*args, **kwargs):
    kwargs = kwargs['kwargs']
    kill_worker_cmd = 'pkill -9 celery'
    subprocess.call(shlex.split(kill_worker_cmd))
    start_worker_cmd = 'celery -A worker worker --loglevel=%s --logfile=%s --uid=%s --gid=%s' % (kwargs['loglevel'], kwargs['logfile'], kwargs['uid'], kwargs['gid'])
    subprocess.call(shlex.split(start_worker_cmd))


class Command(BaseCommand):

    def add_arguments(self, parser):
        parser.add_argument('-lf', '--logfile',
            dest='logfile',
            help='define the logfile')

        parser.add_argument('-ll', '--loglevel',
            dest='loglevel',
            help='define the loglevel')

        parser.add_argument('-u', '--uid',
            dest='uid',
            help='define the worker uid')

        parser.add_argument('-g', '--gid',
            dest='gid',
            help='define the worker gid')


    def handle(self, *args, **options):
        self.stdout.write('Starting celery worker with autoreload...')
        kwargs = {
                'loglevel': options.get('loglevel'),
                'logfile': options.get('logfile'),
                'uid': options.get('uid'),
                'gid': options.get('gid'),
            }
        autoreload.run_with_reloader(restart_celery, args=None, kwargs=kwargs)
{'fraction_non_alphanumeric': 0.14714714714714713, 'fraction_numerical': 0.004804804804804805, 'mean_word_length': 2.768099547511312, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6814945', 'n_tokens_mistral': 1028, 'n_tokens_neox': 977, 'n_words': 192}