Reputation: 2209
I don't like hardcoding things that can be derived from the environment... and so in my god monitors I'd like to use ::Rails.root.to_s or ::Rails.env instead of ENV['RAILS_ENV'] || "production"
Upvotes: 0
Views: 467
Reputation: 65445
You should not load the Rails application from your monitor.
Instead, you should establish required conventions.
The environment variables RACK_ENV
or RAILS_ENV
must be set correctly as environment variables, or there should be some other convention for the whole infrastructure stack knowing what the environment should be. In this example, every single piece of your infrastructure can use the magic formula ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development"
.
The application should be deployed to a well-known location that whole infrastructure stack knows about. For example, every single piece of your infrastructure can use the magic formula Pathname.new("/srv/apps").join(APPLICATION_NAME).join("current").to_s
.
Upvotes: 3