Forum: Ruby on Rails using console is a proper way in produciton?

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.
67259181b4d628f350f5edfafcea6520?d=identicon&s=25 serenobs (Guest)
on 2009-05-22 13:57
(Received via mailing list)
Hello.
I've planned to use script/console to support mainloop for my rails
application.
I need some infinite loop for doing my logic.
For example, I want to give a point every second to users.
to do this task I think I simply code like this:
loop { GivePoint(); sleep 1 } on script/console
and handle taks in the GivePoint method.

Can this way work fine on commercial application?
In fact, script/console looks like sort of helpers to test, so it may
heavy to perform business logic in real world.
Am I right?
Somebody advice on me.

Thanks.
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-05-22 14:00
(Received via mailing list)
On Fri, May 22, 2009 at 1:56 PM, serenobs <serenobs@gmail.com> wrote:
> Can this way work fine on commercial application?
> In fact, script/console looks like sort of helpers to test, so it may
> heavy to perform business logic in real world.
> Am I right?
> Somebody advice on me.
>
> Thanks.
>

You should probably do this in a background task/daemon

Andrew Timberlake
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings
110e527af05961700d9e39285d043b62?d=identicon&s=25 Gianluca Tessarolo (Guest)
on 2009-05-22 14:50
(Received via mailing list)
The best way is to put your code in a model (ex. app/model/batch.rb) or
in a library class (ex. lib/batch.rb) exposing a public method (ex. def
self.run) then create a service that call: script/runner -e production
Batch.run

Hope it helps
This topic is locked and can not be replied to.