From fb7e33de2e525cda48ccd62ff20e7f79c145ebf3 Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Mon, 25 Jan 2016 13:02:53 -0800 Subject: [PATCH] Include appId in __meteor_runtime_config__ for deployed apps This adds `appId` to the `config.json` generated by the bundler, and uses that in `boot.js` to initialize `process.env.APP_ID`. This is used by `autoupdate_server.js` to set `__meteor_runtime_config__`. --- tools/isobuild/bundler.js | 6 ++++++ tools/static-assets/server/boot.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tools/isobuild/bundler.js b/tools/isobuild/bundler.js index 61adb4388a..4ff35697ad 100644 --- a/tools/isobuild/bundler.js +++ b/tools/isobuild/bundler.js @@ -1731,11 +1731,13 @@ class ServerTarget extends JsImageTarget { // options specific to this subclass: // - clientTarget: the ClientTarget to serve up over HTTP as our client // - releaseName: the Meteor release name (for retrieval at runtime) + // - appIdentifier: the app identifier (for retrieval at runtime) constructor (options, ...args) { super(options, ...args); this.clientTargets = options.clientTargets; this.releaseName = options.releaseName; + this.appIdentifier = options.appIdentifier; if (! archinfo.matches(this.arch, "os")) { throw new Error("ServerTarget targeting something that isn't a server?"); @@ -1774,6 +1776,7 @@ class ServerTarget extends JsImageTarget { // server driver alongside the JsImage builder.writeJson("config.json", { meteorRelease: self.releaseName || undefined, + appId: self.appIdentifier || undefined, clientPaths: clientTargetPaths }); @@ -2151,6 +2154,8 @@ exports.bundle = function ({ var builtBy = "Meteor" + (release.current.name ? " " + release.current.name : ""); + var appIdentifier = projectContext.appIdentifier; + var success = false; var serverWatchSet = new watch.WatchSet(); var clientWatchSet = new watch.WatchSet(); @@ -2204,6 +2209,7 @@ exports.bundle = function ({ isopackCache: projectContext.isopackCache, arch: serverArch, releaseName: releaseName, + appIdentifier: appIdentifier, buildMode: buildOptions.buildMode, providePackageJSONForUnavailableBinaryDeps }; diff --git a/tools/static-assets/server/boot.js b/tools/static-assets/server/boot.js index af90acd56a..b39ac44519 100644 --- a/tools/static-assets/server/boot.js +++ b/tools/static-assets/server/boot.js @@ -31,6 +31,9 @@ __meteor_bootstrap__ = { configJson: configJson }; __meteor_runtime_config__ = { meteorRelease: configJson.meteorRelease }; +if (!process.env.APP_ID) { + process.env.APP_ID = configJson.appId; +} // connect (and some other NPM modules) use $NODE_ENV to make some decisions; // eg, if $NODE_ENV is not production, they send stack traces on error. connect