Exemple #1
0
def worker(**options):
    "Run background worker instance."
    from django.conf import settings

    if settings.CELERY_ALWAYS_EAGER:
        raise click.ClickException(
            "Disable CELERY_ALWAYS_EAGER in your settings file to spawn workers."
        )

    # These options are no longer used, but keeping around
    # for backwards compatibility
    for o in "without_gossip", "without_mingle", "without_heartbeat":
        options.pop(o, None)

    from sentry.celery import app

    with managed_bgtasks(role="worker"):
        worker = app.Worker(
            # NOTE: without_mingle breaks everything,
            # we can't get rid of this. Intentionally kept
            # here as a warning. Jobs will not process.
            # without_mingle=True,
            without_gossip=True,
            without_heartbeat=True,
            pool_cls="processes",
            **options)
        worker.start()
        try:
            sys.exit(worker.exitcode)
        except AttributeError:
            # `worker.exitcode` was added in a newer version of Celery:
            # https://github.com/celery/celery/commit/dc28e8a5
            # so this is an attempt to be forwards compatible
            pass
Exemple #2
0
def web(bind, workers, upgrade, with_lock, noinput):
    "Run web service."
    if upgrade:
        click.echo('Performing upgrade before service startup...')
        from sentry.runner import call_command
        try:
            call_command(
                'sentry.runner.commands.upgrade.upgrade',
                verbosity=0,
                noinput=noinput,
                lock=with_lock,
            )
        except click.ClickException:
            if with_lock:
                click.echo(
                    '!! Upgrade currently running from another process, skipping.',
                    err=True)
            else:
                raise

    from sentry.services.http import SentryHTTPServer
    with managed_bgtasks(role='web'):
        SentryHTTPServer(
            host=bind[0],
            port=bind[1],
            workers=workers,
        ).run()
Exemple #3
0
def worker(**options):
    "Run background worker instance."
    from django.conf import settings

    if settings.CELERY_ALWAYS_EAGER:
        raise click.ClickException(
            "Disable CELERY_ALWAYS_EAGER in your settings file to spawn workers."
        )

    from sentry.celery import app

    with managed_bgtasks(role="worker"):
        worker = app.Worker(
            # without_gossip=True,
            # without_mingle=True,
            # without_heartbeat=True,
            pool_cls="processes",
            **options
        )
        worker.start()
        try:
            sys.exit(worker.exitcode)
        except AttributeError:
            # `worker.exitcode` was added in a newer version of Celery:
            # https://github.com/celery/celery/commit/dc28e8a5
            # so this is an attempt to be forwards compatible
            pass
Exemple #4
0
def web(bind, workers, upgrade, with_lock, noinput):
    "Run web service."
    if upgrade:
        click.echo("Performing upgrade before service startup...")
        from sentry.runner import call_command

        try:
            call_command(
                "sentry.runner.commands.upgrade.upgrade",
                verbosity=0,
                noinput=noinput,
                lock=with_lock,
            )
        except click.ClickException:
            if with_lock:
                click.echo(
                    "!! Upgrade currently running from another process, skipping.",
                    err=True)
            else:
                raise

    with managed_bgtasks(role="web"):
        from sentry.services.http import SentryHTTPServer

        SentryHTTPServer(host=bind[0], port=bind[1], workers=workers).run()
Exemple #5
0
def worker(**options):
    "Run background worker instance."
    from django.conf import settings
    if settings.CELERY_ALWAYS_EAGER:
        raise click.ClickException(
            'Disable CELERY_ALWAYS_EAGER in your settings file to spawn workers.'
        )

    from sentry.celery import app
    with managed_bgtasks(role='worker'):
        worker = app.Worker(
            # without_gossip=True,
            # without_mingle=True,
            # without_heartbeat=True,
            pool_cls='processes',
            **options
        )
        worker.start()
        try:
            sys.exit(worker.exitcode)
        except AttributeError:
            # `worker.exitcode` was added in a newer version of Celery:
            # https://github.com/celery/celery/commit/dc28e8a5
            # so this is an attempt to be forwards compatible
            pass
Exemple #6
0
def smtp(bind, upgrade, noinput):
    "Run inbound email service."
    if upgrade:
        click.echo("Performing upgrade before service startup...")
        from sentry.runner import call_command

        call_command("sentry.runner.commands.upgrade.upgrade", verbosity=0, noinput=noinput)

    from sentry.services.smtp import SentrySMTPServer

    with managed_bgtasks(role="smtp"):
        SentrySMTPServer(host=bind[0], port=bind[1]).run()
Exemple #7
0
def web(bind, workers, upgrade, with_lock, noinput, uwsgi):
    "Run web service."
    if upgrade:
        click.echo('Performing upgrade before service startup...')
        from sentry.runner import call_command
        try:
            call_command(
                'sentry.runner.commands.upgrade.upgrade',
                verbosity=0,
                noinput=noinput,
                lock=with_lock,
            )
        except click.ClickException:
            if with_lock:
                click.echo(
                    '!! Upgrade currently running from another process, skipping.',
                    err=True)
            else:
                raise

    with managed_bgtasks(role='web'):
        if not uwsgi:
            click.echo(
                'Running simple HTTP server. Note that chunked file '
                'uploads will likely not work.',
                err=True
            )

            from django.conf import settings

            host = bind[0] or settings.SENTRY_WEB_HOST
            port = bind[1] or settings.SENTRY_WEB_PORT
            click.echo('Address: http://%s:%s/' % (host, port))

            from wsgiref.simple_server import make_server
            from sentry.wsgi import application

            httpd = make_server(
                host,
                port,
                application
            )
            httpd.serve_forever()
        else:
            from sentry.services.http import SentryHTTPServer
            SentryHTTPServer(
                host=bind[0],
                port=bind[1],
                workers=workers,
            ).run()
def cron(**options):
    "Run periodic task dispatcher."
    from django.conf import settings
    if settings.CELERY_ALWAYS_EAGER:
        raise click.ClickException(
            'Disable CELERY_ALWAYS_EAGER in your settings file to spawn workers.'
        )

    from sentry.celery import app
    with managed_bgtasks(role='cron'):
        app.Beat(
            # without_gossip=True,
            # without_mingle=True,
            # without_heartbeat=True,
            **options).run()
Exemple #9
0
def cron(**options):
    "Run periodic task dispatcher."
    from django.conf import settings
    if settings.CELERY_ALWAYS_EAGER:
        raise click.ClickException(
            'Disable CELERY_ALWAYS_EAGER in your settings file to spawn workers.'
        )

    from sentry.celery import app
    with managed_bgtasks(role='cron'):
        app.Beat(
            # without_gossip=True,
            # without_mingle=True,
            # without_heartbeat=True,
            **options
        ).run()
Exemple #10
0
def smtp(bind, upgrade, noinput):
    "Run inbound email service."
    if upgrade:
        click.echo('Performing upgrade before service startup...')
        from sentry.runner import call_command
        call_command(
            'sentry.runner.commands.upgrade.upgrade',
            verbosity=0,
            noinput=noinput,
        )

    from sentry.services.smtp import SentrySMTPServer
    with managed_bgtasks(role='smtp'):
        SentrySMTPServer(
            host=bind[0],
            port=bind[1],
        ).run()