iron-meteor / iron-cli

A scaffolding command line tool for Meteor applications.
640 stars 82 forks source link

Settings not defined after build on Iron #224

Closed Loschcode closed 8 years ago

Loschcode commented 8 years ago

I'm struggling for a while with this and didn't find any stable workaround. My app is working when I do a simple iron run and everything goes fine.

Then I decide to build it into production so I do a iron build which makes the /build/bundle/ files. To try it out I just npm install into the bundle/programs/server and then do a node main.js which output different errors depending on my test, such as

 Error: MONGO_URL must be set in environment
        at Object.<anonymous> (packages/mongo/remote_collection_driver.js:36:1)
        at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
        at new Mongo.Collection (packages/mongo/collection.js:102:1)
        at AccountsServer.AccountsCommon (accounts_common.js:23:18)
        at new AccountsServer (accounts_server.js:16:5)
        at Package (globals_server.js:5:12)
        at /opt/geokaliz/app/programs/server/packages/accounts-base.js:1814:4
        at /opt/geokaliz/app/programs/server/packages/accounts-base.js:1825:3
        at /opt/geokaliz/app/programs/server/boot.js:242:10
        at Array.forEach (native)

The only way to make it work for me was to do a something like METEOR_SETTINGS={\"public\":{\"MAP_ZOOM\":15}} PORT=3000 ROOT_URL=http://localhost:3000 MONGO_URL=mongodb://root:root@localhost:27017/geokaliz node main.js

Which's basically launching the main.js while setting variables on the fly. It works this way. My config/production/settings.json and env.sh aren't taken into consideration by the system when I launch the built application so i've to basically copy them while using the command.

I'm pretty sure there's something very important you didn't mention in the documentation on how to build and deploy your application, or there's a big issue.

I also tried to use mup/mupx for a while and it output more or less the same kind of problem : the settings.json is completely ignored so forever is restarted indefinitely, everything else seems fine.

I'm stuck on this for 3 full days which's not a few hours. I tried everything I could even doing a manual bash I would launch which is like (excerpt)

# Dynamic (no need to touch)
export METEOR_SETTINGS=$(cat $PROJECT_PATH/website/config/$ENV/settings.json)

But for some reason it's not right despite the fact it more or less works in local version, and i can't get it to work on the server anyway (because different architecture, etc.) ; it's not a clean way to process anyway.

My conclusion is : Iron doesn't know / take the settings when building the application for some reason. I didn't find anyway to tell the system to manually for a specific setting file.

What am I missing ? What's wrong with Iron ?