From cb90c72b48cd265386024235aaa9c9325ef6a6fc Mon Sep 17 00:00:00 2001 From: ngken0995 Date: Thu, 5 Oct 2023 12:53:39 -0400 Subject: [PATCH 1/5] check for plausible active state --- frontend/justfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/justfile b/frontend/justfile index e78135defd0..96fa536f343 100644 --- a/frontend/justfile +++ b/frontend/justfile @@ -59,7 +59,7 @@ up *flags: # Wait for all profile services to be up wait-up: up - echo "🚧 TODO" + just wait # Set up user and test site in Plausible init: wait-up @@ -71,3 +71,19 @@ run *args: types: cd .. && pnpm exec vue-tsc -p frontend --noEmit + +########## +# Health # +########## + +# Check the health of the service +@health host="localhost:50288": + -curl -s -o /dev/null -w '%{http_code}' 'http://{{ host }}/api/health' + +# Wait for the service to be healthy +@wait host="localhost:50288": + # The just command on the second line is executed in the context of the + # parent directory and so must be prefixed with `api/`. + just ../_loop \ + '"$(just frontend/health {{ host }})" != "200"' \ + "Waiting for the frontend to be healthy..." From 767cefa9daec646cf62e78472f3a7cbd20abf246 Mon Sep 17 00:00:00 2001 From: ngken0995 Date: Mon, 9 Oct 2023 22:44:54 -0400 Subject: [PATCH 2/5] check plausible health --- frontend/justfile | 4 ++-- frontend/plausible_health_check.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 frontend/plausible_health_check.py diff --git a/frontend/justfile b/frontend/justfile index 96fa536f343..0133a4b3c2e 100644 --- a/frontend/justfile +++ b/frontend/justfile @@ -78,12 +78,12 @@ types: # Check the health of the service @health host="localhost:50288": - -curl -s -o /dev/null -w '%{http_code}' 'http://{{ host }}/api/health' + python3 plausible_health_check.py {{host}} # Wait for the service to be healthy @wait host="localhost:50288": # The just command on the second line is executed in the context of the # parent directory and so must be prefixed with `api/`. just ../_loop \ - '"$(just frontend/health {{ host }})" != "200"' \ + '"$(just frontend/health {{ host }})" != "true"' \ "Waiting for the frontend to be healthy..." diff --git a/frontend/plausible_health_check.py b/frontend/plausible_health_check.py new file mode 100644 index 00000000000..ac9bcc66ac2 --- /dev/null +++ b/frontend/plausible_health_check.py @@ -0,0 +1,22 @@ +import sys + +import requests + + +def main(): + try: + host = sys.argv[1] + url = f"http://{host}/api/health/" + resp = requests.get(url=url) + + information = resp.json() + for data in information: + if information[data] != "ok": + return sys.stdout.write("false") + return sys.stdout.write("true") + except ConnectionError: + pass + + +if __name__ == "__main__": + main() From 2a117b8fab9f4654abe90a26cebe01aabb74bc49 Mon Sep 17 00:00:00 2001 From: ngken0995 Date: Tue, 10 Oct 2023 11:13:55 -0400 Subject: [PATCH 3/5] use curl and grep to check for error --- frontend/justfile | 4 ++-- frontend/plausible_health_check.py | 22 ---------------------- 2 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 frontend/plausible_health_check.py diff --git a/frontend/justfile b/frontend/justfile index 0133a4b3c2e..af2bc3726f4 100644 --- a/frontend/justfile +++ b/frontend/justfile @@ -78,12 +78,12 @@ types: # Check the health of the service @health host="localhost:50288": - python3 plausible_health_check.py {{host}} + -curl -s 'http://localhost:50288/api/health' --fail | grep -v -c 'error' # Wait for the service to be healthy @wait host="localhost:50288": # The just command on the second line is executed in the context of the # parent directory and so must be prefixed with `api/`. just ../_loop \ - '"$(just frontend/health {{ host }})" != "true"' \ + '"$(just frontend/health {{ host }})" != "1" ' \ "Waiting for the frontend to be healthy..." diff --git a/frontend/plausible_health_check.py b/frontend/plausible_health_check.py deleted file mode 100644 index ac9bcc66ac2..00000000000 --- a/frontend/plausible_health_check.py +++ /dev/null @@ -1,22 +0,0 @@ -import sys - -import requests - - -def main(): - try: - host = sys.argv[1] - url = f"http://{host}/api/health/" - resp = requests.get(url=url) - - information = resp.json() - for data in information: - if information[data] != "ok": - return sys.stdout.write("false") - return sys.stdout.write("true") - except ConnectionError: - pass - - -if __name__ == "__main__": - main() From 8079ce563c58dba0a0abaac1c7bbe2a0077dc260 Mon Sep 17 00:00:00 2001 From: ngken0995 Date: Tue, 10 Oct 2023 11:22:42 -0400 Subject: [PATCH 4/5] revise grammar --- frontend/justfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/justfile b/frontend/justfile index af2bc3726f4..dcde236a330 100644 --- a/frontend/justfile +++ b/frontend/justfile @@ -77,13 +77,13 @@ types: ########## # Check the health of the service -@health host="localhost:50288": +@plausible-health host="localhost:50288": -curl -s 'http://localhost:50288/api/health' --fail | grep -v -c 'error' # Wait for the service to be healthy @wait host="localhost:50288": # The just command on the second line is executed in the context of the - # parent directory and so must be prefixed with `api/`. + # parent directory and so must be prefixed with `frontend/`. just ../_loop \ - '"$(just frontend/health {{ host }})" != "1" ' \ - "Waiting for the frontend to be healthy..." + '"$(just frontend/plausible-health {{ host }})" != "1" ' \ + "Waiting for the plausible to be healthy..." From 0f5eb2f0d2715e00d11a86c3a1097b9de008ca37 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Fri, 13 Oct 2023 05:30:24 +0000 Subject: [PATCH 5/5] Correct grammar in waiting message --- frontend/justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/justfile b/frontend/justfile index dcde236a330..24543d1d574 100644 --- a/frontend/justfile +++ b/frontend/justfile @@ -86,4 +86,4 @@ types: # parent directory and so must be prefixed with `frontend/`. just ../_loop \ '"$(just frontend/plausible-health {{ host }})" != "1" ' \ - "Waiting for the plausible to be healthy..." + "Waiting for Plausible to be healthy..."