Exemplo n.º 1
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    has_local_storage = False

    if features.STORAGE_REPLICATION:
        for storage_type, _ in list(
                app.config.get("DISTRIBUTED_STORAGE_CONFIG", {}).values()):
            if storage_type == "LocalStorage":
                has_local_storage = True
                break

    feature_flag = (features.STORAGE_REPLICATION) and (not has_local_storage)
    repl_worker = StorageReplicationWorker(
        image_replication_queue,
        poll_period_seconds=POLL_PERIOD_SECONDS,
        reservation_seconds=RESERVATION_SECONDS,
    )
    worker = GunicornWorker(__name__, app, repl_worker, feature_flag)
    return worker
Exemplo n.º 2
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    worker = GunicornWorker(__name__, app, QueueCleanupWorker(), True)
    return worker
Exemplo n.º 3
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    worker = GunicornWorker(__name__, app, GarbageCollectionWorker(), features.GARBAGE_COLLECTION)
    return worker
Exemplo n.º 4
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    worker = GunicornWorker(__name__, app, ManifestBackfillWorker(),
                            features.MANIFEST_SIZE_BACKFILL)
    return worker
Exemplo n.º 5
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    app.register_blueprint(v2_bp, url_prefix="/v2")
    worker = GunicornWorker(__name__, app, SecurityWorker(), features.SECURITY_SCANNER)
    return worker
Exemplo n.º 6
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    worker = GunicornWorker(__name__, app, RepositoryActionCountWorker(),
                            features.REPOSITORY_ACTION_COUNTER)
    return worker
Exemplo n.º 7
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    feature_flag = (features.ACTION_LOG_ROTATION) or (not None in [SAVE_PATH, SAVE_LOCATION])
    worker = GunicornWorker(__name__, app, LogRotateWorker(), feature_flag)
    return worker
Exemplo n.º 8
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    feature_flag = app.config.get("PROMETHEUS_PUSHGATEWAY_URL") is not None
    worker = GunicornWorker(__name__, app, GlobalPrometheusStatsWorker(), feature_flag)
    return worker
Exemplo n.º 9
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    log_worker = ExportActionLogsWorker(
        export_action_logs_queue, poll_period_seconds=POLL_PERIOD_SECONDS)
    worker = GunicornWorker(__name__, app, log_worker, features.LOG_EXPORT)
    return worker
Exemplo n.º 10
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    feature_flag = (features.APP_SPECIFIC_TOKENS) or (
        app.config.get("EXPIRED_APP_SPECIFIC_TOKEN_GC") is not None)
    worker = GunicornWorker(__name__, app, ExpiredAppSpecificTokenWorker(),
                            feature_flag)
    return worker
Exemplo n.º 11
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    note_worker = NotificationWorker(
        notification_queue, poll_period_seconds=10, reservation_seconds=30, retry_after_seconds=30
    )
    worker = GunicornWorker(__name__, app, note_worker, True)
    return worker
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    feature_flag = features.SECURITY_SCANNER and features.SECURITY_NOTIFICATIONS
    note_worker = SecurityScanningNotificationWorker(
        secscan_notification_queue, poll_period_seconds=_POLL_PERIOD_SECONDS)
    worker = GunicornWorker(__name__, app, note_worker, feature_flag)
    return worker
Exemplo n.º 13
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    feature_flag = (features.TEAM_SYNCING) and (
        authentication.federated_service)
    worker = GunicornWorker(__name__, app, TeamSynchronizationWorker(),
                            feature_flag)
    return worker
Exemplo n.º 14
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    gc_worker = NamespaceGCWorker(
        namespace_gc_queue,
        poll_period_seconds=POLL_PERIOD_SECONDS,
        reservation_seconds=NAMESPACE_GC_TIMEOUT,
    )
    worker = GunicornWorker(__name__, app, gc_worker, features.NAMESPACE_GARBAGE_COLLECTION)
    return worker
Exemplo n.º 15
0
def create_gunicorn_worker():
    """
    follows the gunicorn application factory pattern, enabling
    a quay worker to run as a gunicorn worker thread.

    this is useful when utilizing gunicorn's hot reload in local dev.

    utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
    """
    engines = set([
        config[0] for config in list(
            app.config.get("DISTRIBUTED_STORAGE_CONFIG", {}).values())
    ])
    feature_flag = "SwiftStorage" in engines
    worker = GunicornWorker(
        __name__,
        app,
        ChunkCleanupWorker(chunk_cleanup_queue,
                           poll_period_seconds=POLL_PERIOD_SECONDS),
        feature_flag,
    )
    return worker