-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wait for Plausible active state #3153
Changes from 2 commits
cb90c72
767cefa
2a117b8
8079ce5
0f5eb2f
aa10454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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": | ||||||
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/`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
just ../_loop \ | ||||||
'"$(just frontend/health {{ host }})" != "true"' \ | ||||||
"Waiting for the frontend to be healthy..." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Along the same lines as @sarayourfriend's feedback, this should be updated as follows.
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sys | ||
|
||
import requests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
+1 to Dhruv's comment that try/except is just fine here, totally appropriate usage. |
||
|
||
|
||
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be fine to move the contents of the
wait
recipe here and remove the@wait
recipe below entirely!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is implemented this way for consistency with the API justfile which has both
@wait
andwait-up
. I can get behind this, as this can make working in a Dockerised context locally easier in the future.