[Rails] Running external scripts that know about a minimal Rails env

Kyle Maxwell
Tue, 04 Apr 2006 06:18:57 -0000

On 4/3/06, Nate Agrin <n8agrin@yahoo.com> wrote:
> 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?
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

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