flagsmith-common 3.10.1__tar.gz → 3.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/PKG-INFO +29 -1
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/README.md +27 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/pyproject.toml +2 -1
- flagsmith_common-3.11.0/src/common/core/cli/run.py +79 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/main.py +6 -1
- flagsmith_common-3.11.0/src/task_processor/constants.py +4 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/utils.py +31 -4
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/LICENSE +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/app.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/cli/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/cli/healthcheck.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/constants.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/docgen/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/docgen/events.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/logging.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/docgen.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/start.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/waitfordb.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/metrics.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/middleware.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/otel.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/sentry.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/templates/docgen-events.md +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/templates/docgen-metrics.md +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/urls.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/utils.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/views.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/environments/permissions.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/multivariate/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/multivariate/serializers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/serializers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/versioning/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/versioning/serializers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/conf.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/constants.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/logging.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/metrics.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/metrics_server.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/middleware.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/processors.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/gunicorn/utils.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/lint_tests.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/migrations/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/migrations/helpers/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/migrations/helpers/postgres_helpers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/organisations/permissions.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/projects/permissions.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/prometheus/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/prometheus/utils.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/py.typed +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/test_tools/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/test_tools/plugin.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/test_tools/types.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/test_tools/utils.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/types.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/api.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/constants.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/dynamodb.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/py.typed +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/pydantic_types.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/types.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/utils.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/flagsmith_schemas/validators.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/admin.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/apps.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/decorators.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/exceptions.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/health.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/managers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/metrics.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0001_initial.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0002_healthcheckmodel.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0003_add_completed_to_task.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0004_recreate_task_indexes.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0005_update_conditional_index_conditions.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0006_auto_20230221_0802.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0007_add_is_locked.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0008_add_get_task_to_process_function.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0009_add_recurring_task_run_first_run_at.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0010_task_priority.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0011_add_priority_to_get_tasks_to_process.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0012_add_locked_at_and_timeout.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0013_add_last_picked_at.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0014_add_trace_context.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0015_add_is_disabled.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/0008_get_recurring_tasks_to_process.sql +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/0008_get_tasks_to_process.sql +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/0011_get_tasks_to_process.sql +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/0012_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/0013_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/0015_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/__init__.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/models.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/monitoring.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/processor.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/py.typed +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/routers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/serializers.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/task_registry.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/task_run_method.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/tasks.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/threads.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/types.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/urls.py +0 -0
- {flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/views.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flagsmith-common
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.11.0
|
|
4
4
|
Summary: Flagsmith's common library
|
|
5
5
|
Author: Matthew Elwell, Gagan Trivedi, Kim Gustyr, Zach Aysan, Francesco Lo Franco, Rodrigo López Dato, Evandro Myller, Wadii Zaim
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -39,6 +39,7 @@ Requires-Dist: typing-extensions ; extra == 'otel'
|
|
|
39
39
|
Requires-Dist: backoff>=2.2.1,<3.0.0 ; extra == 'task-processor'
|
|
40
40
|
Requires-Dist: django>4,<6 ; extra == 'task-processor'
|
|
41
41
|
Requires-Dist: django-health-check ; extra == 'task-processor'
|
|
42
|
+
Requires-Dist: environs<16 ; extra == 'task-processor'
|
|
42
43
|
Requires-Dist: opentelemetry-api>=1.25,<2 ; extra == 'task-processor'
|
|
43
44
|
Requires-Dist: prometheus-client>=0.0.16 ; extra == 'task-processor'
|
|
44
45
|
Requires-Dist: pyfakefs>=6,<7 ; extra == 'test-tools'
|
|
@@ -95,6 +96,33 @@ This enables the `route` label for Prometheus HTTP metrics.
|
|
|
95
96
|
|
|
96
97
|
5. To enable the `/metrics` endpoint, set the `PROMETHEUS_ENABLED` setting to `True`.
|
|
97
98
|
|
|
99
|
+
### Startup commands
|
|
100
|
+
|
|
101
|
+
`common.core` registers composite startup verbs on the `flagsmith` command, so a container entrypoint can sequence startup itself rather than via a shell script:
|
|
102
|
+
|
|
103
|
+
- `flagsmith serve` — wait for the database, then start the API.
|
|
104
|
+
- `flagsmith migrate` — migrate each configured database, then create the cache table. A bare invocation runs the full sequence; `flagsmith migrate <app> <name>` defers to Django for targeted migrations.
|
|
105
|
+
- `flagsmith run-task-processor` — migrate, wait for migrations to be applied, then start the Task Processor.
|
|
106
|
+
- `flagsmith migrate-and-serve` — migrate, run any configured startup commands, then start the API.
|
|
107
|
+
|
|
108
|
+
The verbs are configured through these settings:
|
|
109
|
+
|
|
110
|
+
| Setting | Default | Purpose |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `FLAGSMITH_MIGRATE_DATABASES` | `["default"]` | Database aliases the `migrate` step applies, in order. |
|
|
113
|
+
| `FLAGSMITH_WAIT_FOR_MIGRATIONS_DATABASES` | `["default"]` | Database aliases `run-task-processor` waits on before starting. |
|
|
114
|
+
| `FLAGSMITH_STARTUP_COMMANDS` | `[]` | Management commands run, in order, between migrate and serve in `migrate-and-serve`. |
|
|
115
|
+
|
|
116
|
+
…and these environment variables:
|
|
117
|
+
|
|
118
|
+
| Environment variable | Default | Purpose |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| `SKIP_WAIT_FOR_DB` | unset | When set, skip waiting for the database. |
|
|
121
|
+
| `TASK_PROCESSOR_NUM_THREADS` | `5` | Number of worker threads. |
|
|
122
|
+
| `TASK_PROCESSOR_SLEEP_INTERVAL_MS` | `500` | Millis each worker waits before checking for new tasks (falls back to `TASK_PROCESSOR_SLEEP_INTERVAL`). |
|
|
123
|
+
| `TASK_PROCESSOR_GRACE_PERIOD_MS` | `20000` | Millis before a running task is considered stuck. |
|
|
124
|
+
| `TASK_PROCESSOR_QUEUE_POP_SIZE` | `10` | Tasks each worker pops from the queue per cycle. |
|
|
125
|
+
|
|
98
126
|
### Pre-commit hooks
|
|
99
127
|
|
|
100
128
|
This repo provides a [`flagsmith-lint-tests`](.pre-commit-hooks.yaml) hook that enforces test conventions:
|
|
@@ -35,6 +35,33 @@ This enables the `route` label for Prometheus HTTP metrics.
|
|
|
35
35
|
|
|
36
36
|
5. To enable the `/metrics` endpoint, set the `PROMETHEUS_ENABLED` setting to `True`.
|
|
37
37
|
|
|
38
|
+
### Startup commands
|
|
39
|
+
|
|
40
|
+
`common.core` registers composite startup verbs on the `flagsmith` command, so a container entrypoint can sequence startup itself rather than via a shell script:
|
|
41
|
+
|
|
42
|
+
- `flagsmith serve` — wait for the database, then start the API.
|
|
43
|
+
- `flagsmith migrate` — migrate each configured database, then create the cache table. A bare invocation runs the full sequence; `flagsmith migrate <app> <name>` defers to Django for targeted migrations.
|
|
44
|
+
- `flagsmith run-task-processor` — migrate, wait for migrations to be applied, then start the Task Processor.
|
|
45
|
+
- `flagsmith migrate-and-serve` — migrate, run any configured startup commands, then start the API.
|
|
46
|
+
|
|
47
|
+
The verbs are configured through these settings:
|
|
48
|
+
|
|
49
|
+
| Setting | Default | Purpose |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `FLAGSMITH_MIGRATE_DATABASES` | `["default"]` | Database aliases the `migrate` step applies, in order. |
|
|
52
|
+
| `FLAGSMITH_WAIT_FOR_MIGRATIONS_DATABASES` | `["default"]` | Database aliases `run-task-processor` waits on before starting. |
|
|
53
|
+
| `FLAGSMITH_STARTUP_COMMANDS` | `[]` | Management commands run, in order, between migrate and serve in `migrate-and-serve`. |
|
|
54
|
+
|
|
55
|
+
…and these environment variables:
|
|
56
|
+
|
|
57
|
+
| Environment variable | Default | Purpose |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `SKIP_WAIT_FOR_DB` | unset | When set, skip waiting for the database. |
|
|
60
|
+
| `TASK_PROCESSOR_NUM_THREADS` | `5` | Number of worker threads. |
|
|
61
|
+
| `TASK_PROCESSOR_SLEEP_INTERVAL_MS` | `500` | Millis each worker waits before checking for new tasks (falls back to `TASK_PROCESSOR_SLEEP_INTERVAL`). |
|
|
62
|
+
| `TASK_PROCESSOR_GRACE_PERIOD_MS` | `20000` | Millis before a running task is considered stuck. |
|
|
63
|
+
| `TASK_PROCESSOR_QUEUE_POP_SIZE` | `10` | Tasks each worker pops from the queue per cycle. |
|
|
64
|
+
|
|
38
65
|
### Pre-commit hooks
|
|
39
66
|
|
|
40
67
|
This repo provides a [`flagsmith-lint-tests`](.pre-commit-hooks.yaml) hook that enforces test conventions:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flagsmith-common"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.11.0"
|
|
4
4
|
description = "Flagsmith's common library"
|
|
5
5
|
requires-python = ">=3.11,<4.0"
|
|
6
6
|
dependencies = []
|
|
@@ -37,6 +37,7 @@ optional-dependencies = { test-tools = [
|
|
|
37
37
|
"backoff (>=2.2.1,<3.0.0)",
|
|
38
38
|
"django (>4,<6)",
|
|
39
39
|
"django-health-check",
|
|
40
|
+
"environs (<16)",
|
|
40
41
|
"opentelemetry-api (>=1.25,<2)",
|
|
41
42
|
"prometheus-client (>=0.0.16)",
|
|
42
43
|
], flagsmith-schemas = [
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Composite startup verbs for the `flagsmith` entrypoint.
|
|
2
|
+
|
|
3
|
+
These mirror the sequencing that Core API's `run-docker.sh` performed in
|
|
4
|
+
shell, but run in a single process so the Django boot cost is paid once.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import shlex
|
|
9
|
+
|
|
10
|
+
from django.conf import settings
|
|
11
|
+
from django.core.management import (
|
|
12
|
+
execute_from_command_line as django_execute_from_command_line,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
WAIT_FOR_MIGRATIONS_TIMEOUT_SECONDS = 30
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _wait_for_db(
|
|
19
|
+
*,
|
|
20
|
+
wait_for_migrations: bool = False,
|
|
21
|
+
database: str = "default",
|
|
22
|
+
wait_for: int | None = None,
|
|
23
|
+
) -> None:
|
|
24
|
+
if os.environ.get("SKIP_WAIT_FOR_DB"):
|
|
25
|
+
return
|
|
26
|
+
args = ["waitfordb", "--database", database]
|
|
27
|
+
if wait_for is not None:
|
|
28
|
+
args += ["--waitfor", str(wait_for)]
|
|
29
|
+
if wait_for_migrations:
|
|
30
|
+
args.append("--migrations")
|
|
31
|
+
django_execute_from_command_line(["flagsmith", *args])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _migrate() -> None:
|
|
35
|
+
_wait_for_db()
|
|
36
|
+
databases: list[str] = getattr(settings, "FLAGSMITH_MIGRATE_DATABASES", ["default"])
|
|
37
|
+
for database in databases:
|
|
38
|
+
django_execute_from_command_line(
|
|
39
|
+
["flagsmith", "migrate", "--database", database]
|
|
40
|
+
)
|
|
41
|
+
django_execute_from_command_line(["flagsmith", "createcachetable"])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def migrate(argv: list[str], *, prog: str) -> None:
|
|
45
|
+
"""Migrate the configured databases, then create the cache table."""
|
|
46
|
+
if argv:
|
|
47
|
+
django_execute_from_command_line(["flagsmith", "migrate", *argv])
|
|
48
|
+
return
|
|
49
|
+
_migrate()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def serve(argv: list[str], *, prog: str) -> None:
|
|
53
|
+
"""Wait for the database, then start the API server."""
|
|
54
|
+
_wait_for_db()
|
|
55
|
+
django_execute_from_command_line(["flagsmith", "start", "api", *argv])
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def run_task_processor(argv: list[str], *, prog: str) -> None:
|
|
59
|
+
"""Migrate, wait for migrations to be applied, then start the task processor."""
|
|
60
|
+
_migrate()
|
|
61
|
+
databases: list[str] = getattr(
|
|
62
|
+
settings, "FLAGSMITH_WAIT_FOR_MIGRATIONS_DATABASES", ["default"]
|
|
63
|
+
)
|
|
64
|
+
for database in databases:
|
|
65
|
+
_wait_for_db(
|
|
66
|
+
wait_for_migrations=True,
|
|
67
|
+
database=database,
|
|
68
|
+
wait_for=WAIT_FOR_MIGRATIONS_TIMEOUT_SECONDS,
|
|
69
|
+
)
|
|
70
|
+
django_execute_from_command_line(["flagsmith", "start", "task-processor", *argv])
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def migrate_and_serve(argv: list[str], *, prog: str) -> None:
|
|
74
|
+
"""Migrate, run any configured startup commands, then start the API server."""
|
|
75
|
+
_migrate()
|
|
76
|
+
startup_commands: list[str] = getattr(settings, "FLAGSMITH_STARTUP_COMMANDS", [])
|
|
77
|
+
for command in startup_commands:
|
|
78
|
+
django_execute_from_command_line(["flagsmith", *shlex.split(command)])
|
|
79
|
+
django_execute_from_command_line(["flagsmith", "start", "api", *argv])
|
|
@@ -10,7 +10,7 @@ from django.core.management import (
|
|
|
10
10
|
)
|
|
11
11
|
from environs import Env
|
|
12
12
|
|
|
13
|
-
from common.core.cli import healthcheck
|
|
13
|
+
from common.core.cli import healthcheck, run
|
|
14
14
|
from common.core.logging import setup_logging
|
|
15
15
|
from common.gunicorn.processors import make_gunicorn_access_processor
|
|
16
16
|
|
|
@@ -118,6 +118,11 @@ def execute_from_command_line(argv: list[str]) -> None:
|
|
|
118
118
|
# Backwards compatibility for task-processor health checks
|
|
119
119
|
# See https://github.com/Flagsmith/flagsmith-task-processor/issues/24
|
|
120
120
|
"checktaskprocessorthreadhealth": healthcheck.main,
|
|
121
|
+
# Composite startup verbs, formerly run-docker.sh
|
|
122
|
+
"serve": run.serve,
|
|
123
|
+
"migrate": run.migrate,
|
|
124
|
+
"run-task-processor": run.run_task_processor,
|
|
125
|
+
"migrate-and-serve": run.migrate_and_serve,
|
|
121
126
|
}[subcommand]
|
|
122
127
|
except (IndexError, KeyError):
|
|
123
128
|
logger.info("Invoking Django")
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import inspect
|
|
3
3
|
import logging
|
|
4
|
+
import os
|
|
4
5
|
from contextlib import contextmanager
|
|
5
6
|
from typing import Any, Generator
|
|
6
7
|
|
|
8
|
+
from environs import Env
|
|
9
|
+
|
|
10
|
+
from task_processor.constants import (
|
|
11
|
+
DEFAULT_TASK_PROCESSOR_GRACE_PERIOD_MS,
|
|
12
|
+
DEFAULT_TASK_PROCESSOR_NUM_THREADS,
|
|
13
|
+
DEFAULT_TASK_PROCESSOR_QUEUE_POP_SIZE,
|
|
14
|
+
DEFAULT_TASK_PROCESSOR_SLEEP_INTERVAL_MS,
|
|
15
|
+
)
|
|
7
16
|
from task_processor.threads import TaskRunnerCoordinator
|
|
8
17
|
from task_processor.types import TaskCallable, TaskProcessorConfig
|
|
9
18
|
|
|
10
19
|
logger = logging.getLogger(__name__)
|
|
11
20
|
|
|
21
|
+
env = Env()
|
|
22
|
+
|
|
12
23
|
|
|
13
24
|
def get_task_identifier_from_function(
|
|
14
25
|
function: TaskCallable[Any],
|
|
@@ -24,25 +35,41 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
|
|
|
24
35
|
"--numthreads",
|
|
25
36
|
type=int,
|
|
26
37
|
help="Number of worker threads to run.",
|
|
27
|
-
default=
|
|
38
|
+
default=env.int(
|
|
39
|
+
"TASK_PROCESSOR_NUM_THREADS",
|
|
40
|
+
default=DEFAULT_TASK_PROCESSOR_NUM_THREADS,
|
|
41
|
+
),
|
|
28
42
|
)
|
|
29
43
|
parser.add_argument(
|
|
30
44
|
"--sleepintervalms",
|
|
31
45
|
type=int,
|
|
32
46
|
help="Number of millis each worker waits before checking for new tasks",
|
|
33
|
-
default=
|
|
47
|
+
default=(
|
|
48
|
+
env.int("TASK_PROCESSOR_SLEEP_INTERVAL_MS")
|
|
49
|
+
if "TASK_PROCESSOR_SLEEP_INTERVAL_MS" in os.environ
|
|
50
|
+
else env.int(
|
|
51
|
+
"TASK_PROCESSOR_SLEEP_INTERVAL",
|
|
52
|
+
default=DEFAULT_TASK_PROCESSOR_SLEEP_INTERVAL_MS,
|
|
53
|
+
)
|
|
54
|
+
),
|
|
34
55
|
)
|
|
35
56
|
parser.add_argument(
|
|
36
57
|
"--graceperiodms",
|
|
37
58
|
type=int,
|
|
38
59
|
help="Number of millis before running task is considered 'stuck'.",
|
|
39
|
-
default=
|
|
60
|
+
default=env.int(
|
|
61
|
+
"TASK_PROCESSOR_GRACE_PERIOD_MS",
|
|
62
|
+
default=DEFAULT_TASK_PROCESSOR_GRACE_PERIOD_MS,
|
|
63
|
+
),
|
|
40
64
|
)
|
|
41
65
|
parser.add_argument(
|
|
42
66
|
"--queuepopsize",
|
|
43
67
|
type=int,
|
|
44
68
|
help="Number of tasks each worker will pop from the queue on each cycle.",
|
|
45
|
-
default=
|
|
69
|
+
default=env.int(
|
|
70
|
+
"TASK_PROCESSOR_QUEUE_POP_SIZE",
|
|
71
|
+
default=DEFAULT_TASK_PROCESSOR_QUEUE_POP_SIZE,
|
|
72
|
+
),
|
|
46
73
|
)
|
|
47
74
|
|
|
48
75
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/docgen.py
RENAMED
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/start.py
RENAMED
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/management/commands/waitfordb.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/templates/docgen-events.md
RENAMED
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/core/templates/docgen-metrics.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/multivariate/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/multivariate/serializers.py
RENAMED
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/versioning/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/features/versioning/serializers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/common/migrations/helpers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/0001_initial.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-3.10.1 → flagsmith_common-3.11.0}/src/task_processor/migrations/sql/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|