コード例 #1
0
ファイル: run.py プロジェクト: NuttasitBoonwat/sentry
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()
コード例 #2
0
ファイル: upgrade.py プロジェクト: liang0/sentry-1
def _upgrade(interactive, traceback, verbosity, repair, with_nodestore):
    from django.core.management import call_command as dj_call_command

    # migrate legacy south history into new django migrations automatically
    _migrate_from_south(verbosity)

    dj_call_command(
        "migrate",
        interactive=interactive,
        traceback=traceback,
        verbosity=verbosity,
        migrate=True,
        merge=True,
        ignore_ghost_migrations=True,
    )

    if with_nodestore:
        from sentry import nodestore

        nodestore.bootstrap()

    if repair:
        from sentry.runner import call_command

        call_command("sentry.runner.commands.repair.repair")
コード例 #3
0
def start(ctx, service, bind, workers, debug, upgrade, noinput):
    "Start running a service."
    if bind:
        if ':' in bind:
            host, port = bind.split(':', 1)
            port = int(port)
        else:
            host = bind
            port = None
    else:
        host, port = None, None

    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,
        )

    click.echo('Running service: %r' % service)

    # remove command line arguments to avoid optparse failures with service code
    # that calls call_command which reparses the command line, and if --noupgrade is supplied
    # a parse error is thrown
    import sys
    sys.argv = sys.argv[:1]

    from sentry.utils.imports import import_string
    import_string(SERVICES[service])(
        debug=debug,
        host=host,
        port=port,
        workers=workers,
    ).run()
コード例 #4
0
def _upgrade(interactive, traceback, verbosity, repair, with_nodestore):
    from django.core.management import call_command as dj_call_command

    _check_history()

    for db_conn in settings.DATABASES.keys():
        # Always run migrations for the default connection.
        # Also run migrations on connections that have migrations explicitly enabled.
        # This is used for sentry.io as our production database runs on multiple hosts.
        if db_conn == "default" or settings.DATABASES[db_conn].get(
                "RUN_MIGRATIONS", False):
            click.echo(f"Running migrations for {db_conn}")
            dj_call_command(
                "migrate",
                database=db_conn,
                interactive=interactive,
                traceback=traceback,
                verbosity=verbosity,
            )

    if with_nodestore:
        from sentry import nodestore

        nodestore.bootstrap()

    if repair:
        from sentry.runner import call_command

        call_command("sentry.runner.commands.repair.repair")
コード例 #5
0
ファイル: start.py プロジェクト: AyrtonRicardo/sentry
def start(ctx, service, bind, workers, debug, upgrade, noinput):
    "Start running a service."
    if bind:
        if ':' in bind:
            host, port = bind.split(':', 1)
            port = int(port)
        else:
            host = bind
            port = None
    else:
        host, port = None, None

    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,
        )

    click.echo('Running service: %r' % service)

    # remove command line arguments to avoid optparse failures with service code
    # that calls call_command which reparses the command line, and if --noupgrade is supplied
    # a parse error is thrown
    import sys
    sys.argv = sys.argv[:1]

    from sentry.utils.imports import import_string
    import_string(SERVICES[service])(
        debug=debug,
        host=host,
        port=port,
        workers=workers,
    ).run()
コード例 #6
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()
コード例 #7
0
def _upgrade(interactive, traceback, verbosity, repair):
    from django.core.management import call_command as dj_call_command

    if 'south' in settings.INSTALLED_APPS or DJANGO_17:
        dj_call_command(
            'migrate',
            interactive=interactive,
            traceback=traceback,
            verbosity=verbosity,
            migrate=True,
            merge=True,
            ignore_ghost_migrations=True,
        )
    else:
        dj_call_command(
            'syncdb',
            interactive=interactive,
            traceback=traceback,
            verbosity=verbosity,
        )

    if repair:
        from sentry.runner import call_command
        call_command(
            'sentry.runner.commands.repair.repair',
        )
コード例 #8
0
ファイル: users.py プロジェクト: pasala91/test
def create_first_user(app_config, using, interactive, **kwargs):
    if app_config and app_config.name != "sentry":
        return

    try:
        User = app_config.get_model("User")
    except LookupError:
        return

    if User.objects.filter(is_superuser=True).exists():
        return

    if hasattr(router, "allow_migrate"):
        if not router.allow_migrate(using, User):
            return
    else:
        if not router.allow_syncdb(using, User):
            return
    if not interactive:
        return

    import click

    if not click.confirm("\nWould you like to create a user account now?",
                         default=True):
        # Not using `abort=1` because we don't want to exit out from further execution
        click.echo("\nRun `sentry createuser` to do this later.\n")
        return

    from sentry.runner import call_command

    call_command("sentry.runner.commands.createuser.createuser",
                 superuser=True)
コード例 #9
0
def create_first_user(created_models, verbosity, db, app=None, **kwargs):
    # this is super confusing
    if app and app.__name__ != 'sentry.models':
        return

    if User not in created_models:
        return

    if hasattr(router, 'allow_migrate'):
        if not router.allow_migrate(db, User):
            return
    else:
        if not router.allow_syncdb(db, User):
            return
    if not kwargs.get('interactive', True):
        return

    import click
    if not click.confirm('\nWould you like to create a user account now?', default=True):
        # Not using `abort=1` because we don't want to exit out from further execution
        click.echo('\nRun `sentry createuser` to do this later.\n')
        return

    from sentry.runner import call_command
    call_command('sentry.runner.commands.createuser.createuser')
コード例 #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()
コード例 #11
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()
コード例 #12
0
ファイル: users.py プロジェクト: xinranlee/sentry
def create_first_user(app, created_models, verbosity, db, **kwargs):
    if User not in created_models:
        return
    if not kwargs.get('interactive', True):
        return

    import click
    if not click.confirm('\nWould you like to create a user account now?', default=True):
        # Not using `abort=1` because we don't want to exit out from further execution
        click.echo('\nRun `sentry createuser` to do this later.\n')
        return

    from sentry.runner import call_command
    call_command('sentry.runner.commands.createuser.createuser')
コード例 #13
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
    SentrySMTPServer(
        host=bind[0],
        port=bind[1],
    ).run()
コード例 #14
0
def web(bind, workers, upgrade, noinput):
    "Run web 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.http import SentryHTTPServer
    SentryHTTPServer(
        host=bind[0],
        port=bind[1],
        workers=workers,
    ).run()
コード例 #15
0
ファイル: start.py プロジェクト: webZW/sentry
def start(ctx, service, bind, workers, upgrade, noinput):
    "DEPRECATED see `sentry run` instead."

    from sentry.runner.initializer import show_big_error
    show_big_error(
        [
            '`sentry start%s` is deprecated.' % (' ' + service if 'http' in sys.argv else ''),
            'Use `sentry run %s` instead.' % {
                'http': 'web'
            }.get(service, service),
        ]
    )

    if bind:
        if ':' in bind:
            host, port = bind.split(':', 1)
            port = int(port)
        else:
            host = bind
            port = None
    else:
        host, port = None, None

    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,
        )

    click.echo('Running service: %r' % service)

    # remove command line arguments to avoid optparse failures with service code
    # that calls call_command which reparses the command line, and if --noupgrade is supplied
    # a parse error is thrown
    sys.argv = sys.argv[:1]

    from sentry.utils.imports import import_string
    import_string(SERVICES[service])(
        host=host,
        port=port,
        workers=workers,
    ).run()
コード例 #16
0
ファイル: start.py プロジェクト: Kayle009/sentry
def start(ctx, service, bind, workers, upgrade, noinput):
    "DEPRECATED see `sentry run` instead."

    from sentry.runner.initializer import show_big_error
    show_big_error(
        [
            '`sentry start%s` is deprecated.' % (' ' + service if 'http' in sys.argv else ''),
            'Use `sentry run %s` instead.' % {
                'http': 'web'
            }.get(service, service),
        ]
    )

    if bind:
        if ':' in bind:
            host, port = bind.split(':', 1)
            port = int(port)
        else:
            host = bind
            port = None
    else:
        host, port = None, None

    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,
        )

    click.echo('Running service: %r' % service)

    # remove command line arguments to avoid optparse failures with service code
    # that calls call_command which reparses the command line, and if --noupgrade is supplied
    # a parse error is thrown
    sys.argv = sys.argv[:1]

    from sentry.utils.imports import import_string
    import_string(SERVICES[service])(
        host=host,
        port=port,
        workers=workers,
    ).run()
コード例 #17
0
ファイル: upgrade.py プロジェクト: commonlims/commonlims
def _upgrade(interactive, traceback, verbosity, repair):
    from django.core.management import call_command as dj_call_command
    from clims.services import ioc
    dj_call_command(
        'migrate',
        interactive=interactive,
        traceback=traceback,
        verbosity=verbosity,
        migrate=True,
        merge=True,
        ignore_ghost_migrations=True,
    )

    if repair:
        from sentry.runner import call_command
        call_command('sentry.runner.commands.repair.repair', )

    ioc.app.plugins.auto_install()
コード例 #18
0
ファイル: upgrade.py プロジェクト: AyrtonRicardo/sentry
def upgrade(ctx, verbosity, traceback, noinput):
    "Perform any pending database migrations and upgrades."

    from django.core.management import call_command as dj_call_command

    dj_call_command("syncdb", interactive=not noinput, traceback=traceback, verbosity=verbosity)

    dj_call_command(
        "migrate",
        merge=True,
        ignore_ghost_migrations=True,
        interactive=not noinput,
        traceback=traceback,
        verbosity=verbosity,
    )

    from sentry.runner import call_command

    call_command("sentry.runner.commands.repair.repair")
コード例 #19
0
ファイル: upgrade.py プロジェクト: wjk1982/sentry
def _upgrade(interactive, traceback, verbosity):
    from django.core.management import call_command as dj_call_command
    dj_call_command(
        'syncdb',
        interactive=interactive,
        traceback=traceback,
        verbosity=verbosity,
    )

    dj_call_command(
        'migrate',
        merge=True,
        ignore_ghost_migrations=True,
        interactive=interactive,
        traceback=traceback,
        verbosity=verbosity,
    )

    from sentry.runner import call_command
    call_command('sentry.runner.commands.repair.repair', )
コード例 #20
0
ファイル: upgrade.py プロジェクト: ycaihua/sentry-1
def upgrade(ctx, verbosity, traceback, noinput):
    "Perform any pending database migrations and upgrades."

    from django.core.management import call_command as dj_call_command
    dj_call_command(
        'syncdb',
        interactive=not noinput,
        traceback=traceback,
        verbosity=verbosity,
    )

    dj_call_command(
        'migrate',
        merge=True,
        ignore_ghost_migrations=True,
        interactive=not noinput,
        traceback=traceback,
        verbosity=verbosity,
    )

    from sentry.runner import call_command
    call_command('sentry.runner.commands.repair.repair', )
コード例 #21
0
ファイル: upgrade.py プロジェクト: ForkRepo/sentry
def _upgrade(interactive, traceback, verbosity):
    from django.core.management import call_command as dj_call_command
    dj_call_command(
        'syncdb',
        interactive=interactive,
        traceback=traceback,
        verbosity=verbosity,
    )

    dj_call_command(
        'migrate',
        merge=True,
        ignore_ghost_migrations=True,
        interactive=interactive,
        traceback=traceback,
        verbosity=verbosity,
    )

    from sentry.runner import call_command
    call_command(
        'sentry.runner.commands.repair.repair',
    )
コード例 #22
0
ファイル: createsuperuser.py プロジェクト: 280185386/sentry
 def handle(self, **options):
     from sentry.runner import call_command
     call_command(
         'sentry.runner.commands.createuser.createuser',
         superuser=True,
     )
コード例 #23
0
ファイル: createsuperuser.py プロジェクト: liang0/sentry-1
    def handle(self, **options):
        from sentry.runner import call_command

        call_command("sentry.runner.commands.createuser.createuser",
                     superuser=True)