From c885357cc97ad047bac25efac8bbf9989bac7b4d Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 13 Jul 2017 15:28:13 -0700 Subject: [PATCH] Wait for packager to start Reviewed By: shergin Differential Revision: D5408443 fbshipit-source-id: 4a9b37822c1f5c0db3d8be71862d5049bca1ecdd --- scripts/objc-test.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/objc-test.sh b/scripts/objc-test.sh index 15d26dff7e6..62990088cc9 100755 --- a/scripts/objc-test.sh +++ b/scripts/objc-test.sh @@ -31,6 +31,25 @@ function cleanup { } trap cleanup EXIT +# Wait for the package to start +function waitForPackager { + local -i max_attempts=60 + local -i attempt_num=1 + + until $(curl -s http://localhost:8081/status | grep "packager-status:running" -q); do + if (( attempt_num == max_attempts )); then + echo "Packager did not respond in time. No more attempts left." + exit 1 + else + (( attempt_num++ )) + echo "Packager did not respond. Retrying for attempt number $attempt_num..." + sleep 1 + fi + done + + echo "Packager is ready!" +} + # If first argument is "test", actually start the packager and run tests. # Otherwise, just build RNTester for tvOS and exit @@ -41,8 +60,9 @@ open "./scripts/launchPackager.command" || echo "Can't start packager automatica # Start the WebSocket test server open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically" +waitForPackager + # Preload the RNTesterApp bundle for better performance in integration tests -sleep 20 curl 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true' -o temp.bundle rm temp.bundle curl 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true&minify=false' -o temp.bundle