Forum: Ruby on Rails Running external scripts that know about a minimal Rails env

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.
F6789c234864608e0e3fc0b5e4134b30?d=identicon&s=25 Nate Agrin (n8agrin)
on 2006-04-04 04:14
I've been exploring the options for running external scripts from the
Rails env.

The list I have is this:

Cron
ScriptRunner (in the script/ dir under rails projects)
RailsCron

The most likely candidate for me is the ScriptRunner because my external
script needs to know about a model which it has to save to the database
from my Rails environment, and it needs to start running as soon as I
tell it to.  Unfortunately, running this external command many times in
a row is a bottleneck since each ScriptRunner instance has to load up
the entire rails env.

What I'm wondering is what is the easiest way to create a script which
knows only about the model I need to work with, and it's database
location, so that my script doesn't need to load the entire Rails env.

I'm thinking if I can load the activerecord gem with a slim config
setup, that might work, but I'm not sure how to use activerecord outside
the context of the Rail's env.

Anyone else ever tackle this issue?
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-04-04 08:22
(Received via mailing list)
On 4/3/06, Nate Agrin <n8agrin@yahoo.com> wrote:
> script needs to know about a model which it has to save to the database
> setup, that might work, but I'm not sure how to use activerecord outside
>
Hi Nate,
To run a minimal script that just loads the activerecord gem and
connects to mysql on localhost takes just over a second on my G4
powerbook, and the same amount of time on my dedicated linux server.

The other option is a persistant Rails environment, of which RailsCron
is the only one I am aware.  Let me know how you like it.

--
Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
This topic is locked and can not be replied to.