Skip to content

Commit 711218a

Browse files
committed
flagsmith healthcheck
1 parent e6c7b7d commit 711218a

5 files changed

Lines changed: 34 additions & 44 deletions

File tree

api/poetry.lock

Lines changed: 16 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ exclude_also = [
6666
omit = ["scripts/*", "manage.py"]
6767

6868
[tool.pytest.ini_options]
69-
addopts = ['--ds=app.settings.test', '-vvvv', '-p', 'no:warnings', '--dist=worksteal']
69+
addopts = [
70+
'--ds=app.settings.test',
71+
'-vvvv',
72+
'-p',
73+
'no:warnings',
74+
'--dist=worksteal',
75+
]
7076
console_output_style = 'count'
7177

7278
[tool.mypy]
@@ -154,7 +160,7 @@ pygithub = "2.1.1"
154160
hubspot-api-client = "^8.2.1"
155161
djangorestframework-dataclasses = "^1.3.1"
156162
pyotp = "^2.9.0"
157-
flagsmith-common = "^1.10.0"
163+
flagsmith-common = { git = "https://github.com/flagsmith/flagsmith-common", branch = "feat/flagsmith-healthcheck" }
158164
django-stubs = "^5.1.3"
159165
tzdata = "^2024.1"
160166
djangorestframework-simplejwt = "^5.3.1"

api/scripts/healthcheck.py

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
1-
import argparse
2-
import socket
3-
4-
parser = argparse.ArgumentParser(
5-
description="Check if the API is able to accept local TCP connections.",
6-
)
7-
parser.add_argument(
8-
"--port",
9-
"-p",
10-
type=int,
11-
default=8000,
12-
help="Port to check the API on (default: 8000)",
13-
)
14-
parser.add_argument(
15-
"--timeout",
16-
"-t",
17-
type=int,
18-
default=1,
19-
help="Socket timeout for the connection attempt in seconds (default: 1)",
20-
)
21-
22-
23-
def main() -> None:
24-
args = parser.parse_args()
25-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
26-
sock.settimeout(args.timeout)
27-
sock.connect(("localhost", args.port))
28-
sock.close()
1+
import logging
2+
import sys
293

4+
from common.core.main import main
305

316
if __name__ == "__main__":
32-
main()
7+
logging.getLogger(__name__).warning(
8+
f"This healthcheck, invoked by `{' '.join(sys.argv)}``, is deprecated. "
9+
"Please use one of the `flagsmith healthcheck` commands instead."
10+
)
11+
main(["flagsmith", "healthcheck", "http"])

infrastructure/aws/staging/ecs-task-definition-task-processor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"healthCheck": {
2020
"command": [
2121
"CMD-SHELL",
22-
"python scripts/healthcheck.py"
22+
"flagsmith healthcheck tcp"
2323
],
2424
"interval": 10,
2525
"timeout": 2,

infrastructure/aws/staging/ecs-task-definition-web.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"healthCheck": {
2121
"command": [
2222
"CMD-SHELL",
23-
"python scripts/healthcheck.py"
23+
"flagsmith healthcheck tcp"
2424
],
2525
"interval": 10,
2626
"timeout": 2,

0 commit comments

Comments
 (0)