How do I detect in rails if I am running a rake command? -
In the train, you want your environment to do different things at startup, if you are running rack work or No. For example, in the case of my use, many hundred MB cache loading in memory were loaded when the app was launched. We definitely do not want to do it on the rake command.
--- Update --- The following is the reliable solution and works with Herokee.
is_rake = (ENV ['RACK_ENV'] empty ??} ENV ['RAILS_ENV']. Empty? || ("# {ENV.inspect}" = ~ / worker / i ) .blank?)
to find out if your environment is in a rake command then a lot It's easy, but, it took me a while to understand it. I hope someone will help in this!
in # environment.rb, I have the following_is_rake =! ("# {ENV.inspect}" = ~ / rake / i) .blank? Say "what is the rake? # {Is_rake}"
Comments
Post a Comment