I know from heroku that it’s possible to add environment variables by running heroku config:add MY_ENV_VAR=123
locally. How can I achieve the same thing with engineyard?
On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.
The . env file contains the individual user environment variables that override the variables set in the /etc/environment file. You can customize your environment variables as desired by modifying your . env file.
Follow the steps to set environment variables using the Windows GUI: 1. Press Windows + R to open the Windows Run prompt. 2. Type in sysdm.cpl and click OK. 3. Open the Advanced tab and click on the Environment Variables button in the System Properties window. 4. The Environment Variables window is divided into two sections.
Open the Advanced tab and click on the Environment Variables button in the System Properties window. 4. The Environment Variables window is divided into two sections. The sections display user-specific and system-wide environment variables. To add a variable, click the New… button under the appropriate section. 5.
Both the Command Prompt and PowerShell use the echo command to list specific environment variables. The Command prompt uses the following syntax: In Windows PowerShell, use:
Environment variables are key-value pairs a system uses to set up a software environment. The environment variables also play a crucial role in certain installations, such as installing Java on your PC or Raspberry Pi.
We ran into the same issue and asked EngineYard for some assistance. Jim Neath from EY came back with the following response:
Unfortunately, passenger does not get passed environment variables from the system. What you need to do is create a ruby wrapper that defines your environment variables and launch passenger using this, as described here:
http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger/
I have created you a basic custom chef recipe that will do just this:
https://github.com/jimneath/ey-cloud-recipes/tree/master/cookbooks/passenger_env_vars
You will need to update the following file with your environment variables:
/ey-cloud-recipes/blob/master/cookbooks/passenger_env_vars/templates/default/env.custom.erb
I don't think you can =/.
One work-around that we use with our Rails applications is to ssh (ey ssh) to EngineYard and create a file in vim /data/your_app_name/shared/config/exports.rb. This file can look something like this:
ENV["AWS_ACCESS_KEY_ID"] = "your key"
ENV["AWS_SECRET_ACCESS_KEY"] = "your secret"
ENV["AWS_BUCKET"] = "your bucket"
Then in config/boot.rb you require the file:
require File.expand_path('./exports', File.dirname(__FILE__))
This is neither pretty, nor effortless. It however let you use secrets in your app that you should not check into source control!
This is pretty simple for Unicorn using env.custom. Take a look at my answer here https://stackoverflow.com/a/13741463/1520775
If you want to run a rake task (i.e. cron job) that needs these environmental variables, store the variables in /data/my_app/shared/config/env.custom
source /data/my_app/shared/config/env.custom && cd /data/my_app/current/ && bundle exec rake my_rake_task
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With