File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,27 @@ builder_backend_start_postgrest() {
3131 builder_compose up -d postgrest
3232}
3333
34+ builder_backend_wait_for_postgrest () {
35+ local timeout_seconds=" ${1:- 60} "
36+ local port
37+ port=" $( builder_compose port postgrest 3000) "
38+ local url=" http://127.0.0.1:${port##*: } /UserProduct?select=userId&limit=0"
39+ local timeout_at
40+ timeout_at=" $(( $(date +% s) + timeout_seconds)) "
41+
42+ until {
43+ local status
44+ status=" $( curl -s -o /dev/null -w " %{http_code}" " $url " || true) "
45+ [ " $status " -ge 200 ] && [ " $status " -lt 500 ]
46+ }; do
47+ if [ " $( date +%s) " -ge " $timeout_at " ]; then
48+ echo " Timed out waiting for PostgREST" >&2
49+ return 1
50+ fi
51+ sleep 0.2
52+ done
53+ }
54+
3455builder_backend_wait_for_db () {
3556 local timeout_seconds=" ${1:- 60} "
3657 local timeout_at
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ source "$ROOT_DIR/apps/builder/dev/backend.sh"
77builder_backend_init
88
99cleanup () {
10- if [ " ${LOCAL_DEV_CLEANUP:- false } " != " true" ]; then
10+ if [ " ${LOCAL_DEV_CLEANUP:- ${LOCAL_DEV_START_BUILDER :- true} } " != " true" ]; then
1111 return
1212 fi
1313
@@ -29,7 +29,8 @@ builder_backend_wait_for_db
2929builder_backend_bootstrap_if_empty
3030builder_generate_prisma_client auto
3131builder_backend_start_postgrest
32+ builder_backend_wait_for_postgrest
3233
3334if [ " ${LOCAL_DEV_START_BUILDER:- true} " = " true" ]; then
34- exec pnpm --dir " $ROOT_DIR " dev
35+ pnpm --dir " $ROOT_DIR " --filter=@webstudio-is/builder dev
3536fi
Original file line number Diff line number Diff line change 77 "scripts" : {
88 "build" : " pnpm -r --filter='!./fixtures/*' build" ,
99 "dts" : " pnpm -r dts" ,
10- "dev" : " pnpm --filter='@webstudio-is/builder' dev" ,
11- "dev:local" : " bash ./apps/builder/dev/run-local.sh" ,
12- "dev:backend" : " LOCAL_DEV_START_BUILDER=false bash ./apps/builder/dev/run-local.sh" ,
13- "dev:local:reset" : " LOCAL_DEV_RESET_DB=true bash ./apps/builder/dev/run-local.sh" ,
10+ "dev" : " bash ./apps/builder/dev/run-local.sh" ,
1411 "lint" : " oxlint --deny-warnings" ,
1512 "fixtures" : " pnpm -r fixtures:link && pnpm -r fixtures:sync && pnpm -r fixtures:build" ,
1613 "checks" : " pnpm -r test && pnpm -r typecheck && pnpm lint && pnpm fixtures" ,
You can’t perform that action at this time.
0 commit comments