Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6786757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:17:00+00:00 2026-05-26T17:17:00+00:00

I have some ENV variables that are sourced for the deploy user. (Similar to

  • 0

I have some ENV variables that are sourced for the deploy user. (Similar to what Heroku recommends, but without using Heroku.)

My rails app depends on these for certain functions, for example, in application.rb:

config.action_mailer.default_url_options = { host: ENV['MY_HOST'] }

This is necessary because we have several staging hosts. Each host has MY_HOST defined to its correct hostname in .bashrc like so:

export MY_HOST="staging3.example.com"

This allows us to only use one rails staging environment, but still have each host’s correct hostname used for testing, sending email, etc since this can be set on a per-machine basis.

Unfortunately it looks like when I restart Unicorn using USR2 it doesn’t pick up changes to those variables. Doing a hard-stop and start will correctly load any changes.

I’m using preload_app = true which may I’m guessing has something to do with it. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:17:00+00:00Added an answer on May 26, 2026 at 5:17 pm

    In the end I went away from this approach altogether in favor of loading my app config from an app_config.yml file. Ryan Bates covers this approach in Railscast #226.

    The only thing I did differently is that I load a shared app_config.yml for each server I use. Since I’m using capistrano, I just symlink the file on deploy.

    For example, on staging2 my shared/configs/app_config.yml looks like this:

    staging:
      host: "staging2.example.com"
    

    … whereas on staging3 it looks like this:

    staging:
      host: "staging3.example.com"
    

    Now my application.rb has this line instead:

    config.action_mailer.default_url_options = { host: APP_CONFIG[:host] }
    

    I removed the actual config/app_config.yml from git so that it’s not included on deploy. (I moved it to config/app_config.yml.template.) Then on deploy I use a capistrano task to symlink shared/configs/app_config.yml to config/app_config.yml:

    namespace :deploy do
      desc "Symlinks the app_config.yml"
      task :symlink_app_config, :roles => [:web, :app, :db] do
        run "ln -nfs #{deploy_to}/shared/config/app_config.yml #{release_path}/config/app_config.yml"
      end
    end
    

    This strategy has these benefits over using ENV vars:

    • Deployed to all nodes via capistrano
    • We can do conditional hosts by simply changing the file on the appropriate server
    • Unicorn will get changes with USR2 since everything’s done inside of rails
    • Everything’s kept in one place, and the environment isn’t affected by some other variables outside of the codebase
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some UI in VB 2005 that looks great in XP Style, but
I have some lovely (Scandinavian?) user on my website complaining that I cannot parse
Env.: VS 2008, .NET 2.0, WinForms I have a listview in Tile mode. Some
We have some input data that sometimes appears with &nbsp characters on the end.
We have some files on our website that users of our software can download.
I am using cruisecontrol and ant to build some legacy executables that also depend
I have some proxy settings that I only occasionally want to turn on, so
Typically, in PowerShell you would use env:VARIABLE = Some kind of value But my
Is it possible in some way to have dynamic environment variables in Linux? I
I have a shared server running passenger to server my Rails app. For some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.