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__`.
This commit is contained in:
Martijn Walraven
2016-01-25 13:02:53 -08:00
parent 905c179908
commit fb7e33de2e
2 changed files with 9 additions and 0 deletions

View File

@@ -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
};

View File

@@ -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