开发者

Is there a way to know that a rails app has been launched from a rake command?

开发者 https://www.devze.com 2023-01-23 11:00 出处:网络
I\'m doing a bunch of caching tasks in my rails initializers. They\'re useful for the website, but absolutely useless and time consuming when I launch rake tasks.

I'm doing a bunch of caching tasks in my rails initializers. They're useful for the website, but absolutely useless and time consuming when I launch rake tasks.

Is there a way in rails开发者_StackOverflow中文版 to know when the app has been launched from a rake command?

Thanks


I guess the other option is to ask whether you can tell whether the app has been launched as a website and only run the initializers then.

In that case you should be able to set environment variables in whichever web server you are running the application and you may then be able to trigger your initializer when the environment variable is set. Something like:

if ENV['INITIALIZE_BLAH']
   # Do your website only initialization
end
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号