Forum: Ruby on Rails Can rails environments be loaded only once and then execute rake tasks without loading it again an

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Canvas (Guest)
on 2009-04-25 01:16
(Received via mailing list)
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 (Guest)
on 2009-05-02 10:10
(Received via mailing list)
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
This topic is locked and can not be replied to.