mobile app hot code update issues in production

372 views
Skip to first unread message

Garret Cox

unread,
Nov 26, 2014, 6:22:17 PM11/26/14
to meteo...@googlegroups.com
So, I'd like to employ mobile app hot code pushing. My project is still on 9.4, as there are some bugs that'd take some work to move to version 1, but if that'd solve the below problems, I'll tackle it.

Anyway, everything works perfectly when I run the server with:
meteor --production --mobile-server https://productionserver.com
(of course, it works fine with dev, etc)
I can change a file, the mobile app downloads the update and reloads, etc.

However, when I try to host it with nginx phusion passenger, I don't know how to pass along the --mobile-server setting. As such, if I update a client file and trigger a hot code push, after the mobile app gets the instruction to update, it starts trying to download the files from http://10.0.2.2
This is the same behavior I see if I try to do a hot code push after running:
meteor --production (omitting the --mobile-server option), so I'm pretty sure not being able to pass this setting along to passenger is the root of my problem.
I was hoping it could be passed along as an environment variable, but I see no mention of it in the documentation.

Now, I know one supposed way to get around this is to use meteor build --server https://productionserver.com
this bakes in the server setting, and I just configure passenger to host the create node bundle instead.
This gets me past the previous bug, but introduces a new one:

when hosting from a meteor bundle, the app fails when trying to retrieve:

sure enough, if I go into the meteor code directory and run
meteor --production --mobile-server https://productionserver.com
I can go to https://productionserver.com/__cordova/manifest.json using my web browser and get a nice listing of all the files.
But if I go into the bundle directory and run node main.js, if I try to browse to https://productionserver.com/__cordova/manifest.json I get page not found.

So it appears that a meteor build bundle doesn't respond to this url. I've tried running the bundle both with "node main.js" and by pointing nginx passenger to the bundle, and they both exhibit the same behavior.


Anyway, help solving either issue would get this resolved for me:
1. is there a way to pass along --mobile-server to meteor from nginx passenger, as an environment variable, cgi param, or otherwise?
2. is there some trick to getting a meteor build bundle to generate a /__cordova/manifest.json as a static file, or at least respond to that url?

Thanks for your time!

Slava Kim

unread,
Nov 26, 2014, 6:57:09 PM11/26/14
to meteo...@googlegroups.com
Hi, I worked on the Cordova integration for Meteor and I am sorry to hear you are having this confusion.

Phusion Passenger is not something I had a chance to work with and I don't know how it wraps Meteor.

Judging by 10.0.2.2, you are running on Android and the app wants to connect to localhost - this is surely not right in production. Usually when you want to run a Meteor app in production, you would bundle it with `meteor build` command and this build command actually accepts the 'server' option pointing at the url you want to host on. For example: `meteor build ../build --directory --server https://productionserver.com`.

The __cordova/manifest.json file is generated dynamically by the webserver, there is no easy way to make it static, unless you handle such url yourself with your nginx setup.

Slava

Garret Cox

unread,
Nov 26, 2014, 7:43:42 PM11/26/14
to meteo...@googlegroups.com
Thanks for the reply Slava!

1. Don't worry so much about passenger, except to know that there is no way to pass options to meteor on the command line. Is there a way to pass an environment variable to meteor to specify a remote server in lieu of the --mobile-server option? Or can I hardcode this by setting a variable in the code, or passing in settings via the METEOR_SETTINGS environment variable?

2. I noticed that ___cordova/manifest.json is generated dynamically, and this works perfectly when I use meteor run.
The problem is that when I use meteor build, and run node main.js in the built directory, this doesn't work. Instead I get a page not found error. Do you have any idea what I might be doing wrong?

One suspicion was this: I can't do the meteor build for the server on my dev machine (different OS). When I do the build on the server machine, i have to remove to the 2 mobile platforms from the meteor directory, as the SDKs aren't installed on the server. Does removing these platforms result in the built bundle not being able to generate __cordova/manifest.json?

Slava Kim

unread,
Nov 26, 2014, 7:49:59 PM11/26/14
to meteo...@googlegroups.com
1. I believe it is ROOT_URL

2. This means that when you built a server bundle for the passenger (or passenger built it for you?) neither of the mobile platforms were present in the project. That's it, it is like `meteor add-platform android` was never ran on the project. When there are no mobile platforms in the project, meteor tool doesn't even bother building the mobile part for HCP and putting it into the server bundle (it would need to serve it on hot code push). So it seems to be skipped in your case.

--
You received this message because you are subscribed to a topic in the Google Groups "meteor-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meteor-talk/72Rv67Cp5cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meteor-talk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meteor-talk/1fea9def-07be-425c-bb3d-76f64e3a3514%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Garret Cox

unread,
Nov 27, 2014, 2:01:48 AM11/27/14
to meteo...@googlegroups.com
Thanks Slava, I've got it working now!
For anyone else stumbling on this post....

1. It was as I suspected and Slava confirmed, you HAVE to have at least one mobile platform added to the project before doing the build, or it simply doesn't include in the bundle the functionality needed for your mobile apps.
Feature Request: Slava, in a future version of meteor, it would be helpful to find a way around this. Perhaps even the ability to add a "blank" or "general mobile" platform, just to get this functionality in the server bundle.
Take my example: I had to install all the android SDK stuff on a rather lean server just so that the build would proceed.

2. ROOT_URL does not accomplish the same thing as --mobile-server, as I was passing that, and my apps were still looking for at 10.0.2.2. This could be another feature request: give us the ability to pass the mobile-server command line option as an environment variable for when we are hosting using something like passenger.




Slava Kim

unread,
Nov 27, 2014, 2:06:23 AM11/27/14
to meteo...@googlegroups.com
Garret, we added a platform "firefoxos" exactly to be able to build a mobile platform w/o native SDKs. Sorry for your confusion, I agree that it is nowhere to be found in either docs, nor it is intuitive. There is a lot of work to do on documenting the mobile stuff and making it more intuitive.

--
You received this message because you are subscribed to a topic in the Google Groups "meteor-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meteor-talk/72Rv67Cp5cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meteor-talk...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages