Reputation: 1443
We have a Sinatra / Rack application. We're using Nginx with the Passenger module installed, and the Sinatra / Rack app is being instantiated by Passenger (I hope I'm getting all the verbs correct here).
Configuration for my Rack application comes in the form of command line arguments (e.g. mqhost=localhost mqport=5672 mquser=foo mqpass=bar
). These are accessed in the Rack app via ENV['mqhost']
.
All these parameters are also set as environment variables, e.g. $MQHOST
, $MQPORT
, etc.
Q1: How do I get Passenger to pass these command line arguments to the Rack app when it instantiates it?
Q2: If I cannot pass these as command line arguments, is there a way I can force Passenger to call a bash script that sets these environment variables?
I've checked the documentation and another dev and I spent an hour or two trying various things to little success.
Upvotes: 0
Views: 705
Reputation: 18944
You can't.
You don't have to use a bash script. Just set it directly with passenger_set_cgi_param
. There's a whole chapter in the manual regarding environment variables: https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#about_environment_variables
But if you really want to do it from a bash script, try using the wrapper script approach: http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger/
Upvotes: 1