Canvas
2009-Apr-24 20:44 UTC
Can rails environments be loaded only once and then execute rake tasks without loading it again and again?
Hi there guys, I have a daemon that executes a rake task periodically in a loop in the backend. And every time it runs the rake task, rails environment is reloaded. Is there a way that the rails environment is loaded only once before the loop and the following rake task will not load it again and again? Thank you in advance.
Phlip
2009-May-02 06:09 UTC
Re: Can rails environments be loaded only once and then execute rake tasks without loading it again and again?
Canvas wrote:> I have a daemon that executes a rake task periodically in a loop in > the backend. And every time it runs the rake task, rails environment > is reloaded. Is there a way that the rails environment is loaded only > once before the loop and the following rake task will not load it > again and again?rake tasks are only for user-programmers to enter into command lines. (Like ''make'' in legacy programming. You wouldn''t make over and over again on a server!) rake tasks are for things like migrating the DB or running your tests. (And yes it would be nice for them to run faster!) You need to configure your daemon to simply run script/runner my_script.rb. That invokes the correct environment, and generally builds a miniature Rails machine that models and (I suspect) controllers can run in. However, if you actually do correlate file times with tasks (the root principle of *ake technology), then you either need to express that correlation explicitely, or use a rake task to do it! -- Phlip
Seemingly Similar Threads
- how to exec a directory creation before downloading a file to that directory?
- Question: write an R script with help information available to the user
- Shell Scripting Random Delay
- rake db:migrate - error 'tSYMBEG'
- Running wine from php pages with "Xvfb" not success for my machine