From ceeb06eb1aa72cfb77c5a46fd8fe110f978fe996 Mon Sep 17 00:00:00 2001 From: Justin Carmony Date: Tue, 31 Mar 2015 23:41:15 -0700 Subject: [PATCH] Packager status page & build validating against it. Summary: Creating a packager status page so React can validate a proper packager instance is running on 8081. See #257 for details on this bug. The biggest thing in this PR is I have it perform an exit 2 in the build script if the check fails. This will cause the build to fail, they can click on the error and see a nice message. Not sure if there is a way to throw a warning instead. Also, I broke the bash script into several lines, in the Xcode editor it looks fine but in the source code it looks less than ideal. We might want to break that out into it's own bash script that is called. Let me know if you want to do that. Closes https://github.com/facebook/react-native/pull/308 Github Author: Justin Carmony Test Plan: Imported from GitHub, without a `Test Plan:` line. --- packager.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packager.js b/packager.js index 9503df6e..ad47d1d9 100644 --- a/packager.js +++ b/packager.js @@ -150,6 +150,17 @@ function getDevToolsLauncher(options) { }; } +// A status page so the React/project.pbxproj build script +// can verify that packager is running on 8081 and not +// another program / service. +function statusPageMiddleware(req, res, next) { + if (req.url === '/status') { + res.end('packager-status:running'); + } else { + next(); + } +} + function getAppMiddleware(options) { return ReactPackager.middleware({ projectRoots: options.projectRoots, @@ -168,6 +179,7 @@ function runServer( .use(loadRawBody) .use(openStackFrameInEditor) .use(getDevToolsLauncher(options)) + .use(statusPageMiddleware) .use(getAppMiddleware(options)); options.projectRoots.forEach(function(root) {