You tried putting passenger_env_var in the sites_enabled/[sitename] file, in a server block?
Yes I did, the configuration already works properly if I deploy as a node build.
If I deploy as a meteor app, the settings get silently swallowed by meteor.
Ah ok, maybe you don’t need it anymore if it’s Passenger + Meteor (not node), but you need to use -settings /path/to/settings.json instead?
That directive expects first param to be METEOR_SETTINGS and second param to be a valid json string, so a path to the settings.json file throws an error.
The problem seems to have followed this timeline:
-
Meteor used to allow both meteor_settings and --settings during meteor run and meteor_settings for meteor build deployments
-
passenger supported settings for build deployment, but not for meteor run
-
passenger added support, passing in meteor_settings to meteor run
-
meteor changed settings handling and made meteor_settings applied either for meteor tool or node, and --settings flag only applied to meteor run through a json file
-
passenger did not update its code to reflect that change
So now, what happens is, if you pass in meteor_settings to a meteor run through passenger:
-
if it is a file path, nginx fails to start
-
if it is invalid json, nginx starts but meteor fails to start
-
if it is valid json (the correct settings), it gets ignored by meteor
But if you pass in meteor_settings to a node build through passenger
it works!
My problem is, I was very happy with the previous way it worked, namely to be able to run passenger to manage either meteor run or meteor build and apply my settings either way. That was a very good flexibility providing my efficiency. Now if I use any kind of settings in my app, I either can’t use passenger, or I must meteor build and use that in passenger.
Hi, I tried set nginx with this just like you. But could not read the setting.
passenger_env_var METEOR_SETTINGS '{"private": {"key": "value"}}'
Did log and got error: ReferenceError: METEOR_SETTINGS is not defined
console.log(METEOR_SETTINGS);
Any luck on your side?
When I do
passenger_env_var METEOR_SETTINGS '{"private": {"key": "value"}}'
Your app can see those settings through
console.log(Meteor.settings.private.key) // value
Thanks for reply. I had it working.
I am looking for passing settings via file but not passenger_env_var.
There used to have the option but it gone.
meteor build --settings
If you know how to ship app with setting file, please let me know.
Many thanks.
I use
meteor build --settings
under development mode. It works.
But for production, I have to set required env variables in the nginx config file. uses the
passenger_env_var
directive.
According to meteor build --help
that command option does not have a directive --settings
I am also trying to figure out a way to deploy a meteor app with passenger, and so far I have not been very successful. As a matter of fact, I can’t even get passenger to start with the output of meteor build.
Does anybody have a dead simple recipe that works for nginx + passenger + meteor build (1.2.1)? google finds many answers, but most are outdated or incomplete.
could you post your current conf?
Here is my conf (OSX with homebrew)
server {
server_name www.example.com;
# Turn on Passenger
passenger_enabled on;
root /Volumes/Web/Meteor/build/bundle/public;
passenger_app_type node;
passenger_startup_file main.js;
#
# Tell your app where MongoDB is
#
passenger_env_var ROOT_URL http://www.example.com;
passenger_env_var MONGO_URL mongodb://192.168.1.189:27017/www_example_com;
passenger_env_var MONGO_OPLOG_URL mongodb://192.168.1.189:27017/local;
}
I did the npm install --production
in bundle/programs/server but it throws
bundle/programs/server/node_modules/fibers/future.js:245
throw(ex);
^
Error: Module did not self-register.
First off, you can provide your app your settings as I described over here
And in your case, it seems like you may be having a problem with your node version.
It should be 0.10.40
and you may be having a newer one getting picked up by passenger, which you can fix with the passenger_nodejs configuration option.
Damnit, forgot about that. I also run other node apps via passenger on my Mac, and they work fine with 0.12 node. I will use the node binary from meteor and see what happens. Thanks for pointing that out.
That can be used as a per-server-block configuration so you can use it only for your meteor app’s configurations and passenger will use the default 0.12 for all your other node apps.
Using the node binary from Meteor with passenger_nodejs worked. Thank you for pointing that out
Anyone tried supplying a path & filename for METEOR_SETTINGS in the passenger_env_var? I never thought about actually pasting JSON into the .confs, lol.
There’s now native support for Meteor Settings file in Passenger
afaik that has always been the case, but it is only supported for unbundled meteor apps. once you’ve run meteor build and deploy using that, you still need to use the environment variable
hi
I am running meteor passenger in bundled mode on ubuntu 16.04.
Everything works great but when I add passenger_env_var METEOR_SETTINGS
as shown below my app crashes
server {
listen 443;
server_name xxx.de
...
passenger_env_var MONGO_URL mongodb://localhost:27017/db;
passenger_env_var METEOR_SETTINGS '{"private": {"MAIL_URL": "smtp://finn@MAILSETTINGS"}}'
}
with the following error @ systemctl status nginx.service
Jan 11 15:55:24 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jan 11 15:55:24 nginx[2229]: nginx: [emerg] invalid number of arguments in "passenger_env_var" directive in /etc/nginx/sites-enabled/site.conf:33
Jan 11 15:55:24 nginx[2229]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 11 15:55:24 systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 11 15:55:24 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jan 11 15:55:24 systemd[1]: nginx.service: Unit entered failed state.
Jan 11 15:55:24 systemd[1]: nginx.service: Failed with result 'exit-code'.
anyone know why?