Alder Green
2006-Mar-24 08:20 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
Hi there I''m considering Rails for a new web-application planned to be built from scratch. The application has an extensive web front, and in fact most of the application is interfaced through that front and engaged through clients'' HTTP requests (i.e. the conventional way web-applications and "dynamic web-sites" work). However, some essential parts are supposed to operate more like a non-web server-application: they are supposed to be initiated by a scheduler, without any prior client HTTP request. My questions are: 1. How suitable is Rails for such an application? How suitable is it for an application where core parts of the logic are not associated with any web concept (not coupled to HTML, HTTP, sending pages to clients, etc.)? 2. How easy is it to run scheduled Rails tasks? Is Rails suitable for that? 3. Finally: I''m planning to go with a rather conventional, mass-market host (probably DreamHost) with shared hosting. Would the answers to 1 and 2 still be valid for such a hosting solution? Or would I need a dedicated server? Regards, Alder Green
look at script/runner...a tool for accessing models and their methods from the command line... script/runner is made just for your purpose and fits nice into a host with cron or some other scheduler On Friday, March 24, 2006, at 10:20 AM, Alder Green wrote:>Hi there > >I''m considering Rails for a new web-application planned to be built >from scratch. > >The application has an extensive web front, and in fact most of the >application is interfaced through that front and engaged through >clients'' HTTP requests (i.e. the conventional way web-applications and >"dynamic web-sites" work). However, some essential parts are supposed >to operate more like a non-web server-application: they are supposed >to be initiated by a scheduler, without any prior client HTTP request. > >My questions are: > >1. How suitable is Rails for such an application? How suitable is it >for an application where core parts of the logic are not associated >with any web concept (not coupled to HTML, HTTP, sending pages to >clients, etc.)? > >2. How easy is it to run scheduled Rails tasks? Is Rails suitable >for that? > >3. Finally: I''m planning to go with a rather conventional, mass-market >host (probably DreamHost) with shared hosting. Would the answers to 1 >and 2 still be valid for such a hosting solution? Or would I need a >dedicated server? > >Regards, >Alder Green >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsMikkel Bruun www.strongside.dk - Football Portal(DK) nflfeed.helenius.org - Football News(DK) ting.minline.dk - Buy Old Stuff!(DK) -- Posted with http://DevLists.com. Sign up and save your time!
Larkin Cunningham
2006-Mar-24 09:11 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
Alder, Simply use plain Ruby for the scheduled parts of your application, or whatever scripting / programming language you are comfortable with (PHP, etc). Rails is for web applications using the MVC pattern. Not really suitable for scheduled tasks IMO unless you go and schedule calls to HTTP pages. You could incorporate bits of Rails into your scheduled scripts, e.g. ActiveRecord. If you are prepared to go to the cost of a dedicated server, why not just go for specialised Rails hosting? Ask if they support user added cron jobs. Obviously a dedicated server is the most flexible solution, but only if you can justify the expense (including backups, etc) and the extra admin time. Larkin On 3/24/06, Alder Green <alder.green@gmail.com> wrote:> > Hi there > > I''m considering Rails for a new web-application planned to be built > from scratch. > > The application has an extensive web front, and in fact most of the > application is interfaced through that front and engaged through > clients'' HTTP requests (i.e. the conventional way web-applications and > "dynamic web-sites" work). However, some essential parts are supposed > to operate more like a non-web server-application: they are supposed > to be initiated by a scheduler, without any prior client HTTP request. > > My questions are: > > 1. How suitable is Rails for such an application? How suitable is it > for an application where core parts of the logic are not associated > with any web concept (not coupled to HTML, HTTP, sending pages to > clients, etc.)? > > 2. How easy is it to run scheduled Rails tasks? Is Rails suitable for > that? > > 3. Finally: I''m planning to go with a rather conventional, mass-market > host (probably DreamHost) with shared hosting. Would the answers to 1 > and 2 still be valid for such a hosting solution? Or would I need a > dedicated server? > > Regards, > Alder Green > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/5a6f6bed/attachment.html
Alder Green
2006-Mar-24 10:58 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
Hi I know Ruby well, so I''ll probably just use it. Note that I''d still be using parts of Rails'' MVC, in particular the Models. Mikkel Bruun suggested it would be possible to accomplish through script/runner. If that''s indeed the case, I could schedule script/runner runs with with cron (cron is available on shared hosting solutions, right?) and there''s no reason not to use Rails and my favorite language, Ruby :) Cheers, Alder On 3/24/06, Larkin Cunningham <larkin.cunningham@gmail.com> wrote:> Alder, > > Simply use plain Ruby for the scheduled parts of your application, or > whatever scripting / programming language you are comfortable with (PHP, > etc). Rails is for web applications using the MVC pattern. Not really > suitable for scheduled tasks IMO unless you go and schedule calls to HTTP > pages. You could incorporate bits of Rails into your scheduled scripts, e.g. > ActiveRecord. > > If you are prepared to go to the cost of a dedicated server, why not just > go for specialised Rails hosting? Ask if they support user added cron jobs. > Obviously a dedicated server is the most flexible solution, but only if you > can justify the expense (including backups, etc) and the extra admin time. > > Larkin > > > On 3/24/06, Alder Green <alder.green@gmail.com> wrote: > > > Hi there > > I''m considering Rails for a new web-application planned to be built > from scratch. > > The application has an extensive web front, and in fact most of the > application is interfaced through that front and engaged through > clients'' HTTP requests (i.e. the conventional way web-applications and > "dynamic web-sites" work). However, some essential parts are supposed > to operate more like a non-web server-application: they are supposed > to be initiated by a scheduler, without any prior client HTTP request. > > My questions are: > > 1. How suitable is Rails for such an application? How suitable is it > for an application where core parts of the logic are not associated > with any web concept (not coupled to HTML, HTTP, sending pages to > clients, etc.)? > > 2. How easy is it to run scheduled Rails tasks? Is Rails suitable for that? > > 3. Finally: I''m planning to go with a rather conventional, mass-market > host (probably DreamHost) with shared hosting. Would the answers to 1 > and 2 still be valid for such a hosting solution? Or would I need a > dedicated server? > > Regards, > Alder Green > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Tom Mornini
2006-Mar-24 11:36 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
On Mar 24, 2006, at 2:58 AM, Alder Green wrote:> I know Ruby well, so I''ll probably just use it. Note that I''d still be > using parts of Rails'' MVC, in particular the Models. Mikkel Bruun > suggested it would be possible to accomplish through script/runner. If > that''s indeed the case, I could schedule script/runner runs with with > cron (cron is available on shared hosting solutions, right?) and > there''s no reason not to use Rails and my favorite language, Ruby :)script/runner is wonderful as it allows use of the entire RoR application environment including models, environment constants and configurations, etc. See also rails_cron, as it allows you to dispense with cron. As much as I *love* cron, rails_cron is even better because now, when installing on a new machine, you don''t have to remember to install the cron events as well! :-) -- -- Tom Mornini
Robby Russell
2006-Mar-24 14:03 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
On Fri, 2006-03-24 at 12:58 +0200, Alder Green wrote:> Hi > > I know Ruby well, so I''ll probably just use it. Note that I''d still be > using parts of Rails'' MVC, in particular the Models. Mikkel Bruun > suggested it would be possible to accomplish through script/runner. If > that''s indeed the case, I could schedule script/runner runs with with > cron (cron is available on shared hosting solutions, right?) and > there''s no reason not to use Rails and my favorite language, Ruby :)Cron + script/runner is perfect for this... and so are scheduled rake tasks. -Robby -- /************************************************************** * Robby Russell, Founder & Executive Director * * PLANET ARGON, LLC | www.planetargon.com * * Ruby on Rails Development, Consulting, and Hosting * * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * * blog: www.robbyonrails.com | book: www.programmingrails.com * ***************************************************************/
Brian Hogan
2006-Mar-24 15:40 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
+1 on script/runner. My solution for a recent project was to make a model (non-active-record) that has class methods for all of the things I want to run command-line. class Run def self.cleanup_db end def self.send_weekly_emails end end So then I can just do ruby script/runner "Run.send_weekly_emails" and everything''s nice and clear. On 3/24/06, Robby Russell <robby.lists@planetargon.com> wrote:> > On Fri, 2006-03-24 at 12:58 +0200, Alder Green wrote: > > Hi > > > > I know Ruby well, so I''ll probably just use it. Note that I''d still be > > using parts of Rails'' MVC, in particular the Models. Mikkel Bruun > > suggested it would be possible to accomplish through script/runner. If > > that''s indeed the case, I could schedule script/runner runs with with > > cron (cron is available on shared hosting solutions, right?) and > > there''s no reason not to use Rails and my favorite language, Ruby :) > > Cron + script/runner is perfect for this... and so are scheduled rake > tasks. > > > -Robby > > -- > /************************************************************** > * Robby Russell, Founder & Executive Director * > * PLANET ARGON, LLC | www.planetargon.com * > * Ruby on Rails Development, Consulting, and Hosting * > * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * > * blog: www.robbyonrails.com | book: www.programmingrails.com * > ***************************************************************/ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/4666605b/attachment.html
Alder Green
2006-Mar-26 17:16 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
Ok, kind thanks for everyone who contributed to this thread. Looks like the most natural solution is cron + script/runner, with Brain Hogan''s neat "runner-model" as a convenient way to organize various tasks (especially since there indeed might be more than a few). Tom Mornini''s suggestion of rails_cron sounds interesting, as does Rake scheduled tasks (especially for me as was planning to close a knowledge-gap wrt Rake in any case) suggested by Robby Russel. The requirements sound feasible, in any case, and I hope I would indeed be able to accomplish the project''s goals with Rails. Regards, Alder Green On 3/24/06, Brian Hogan <bphogan@gmail.com> wrote:> +1 on script/runner. > > My solution for a recent project was to make a model (non-active-record) > that has class methods for all of the things I want to run command-line. > > class Run > def self.cleanup_db > > end > > def self.send_weekly_emails > > end > > end > > So then I can just do > ruby script/runner "Run.send_weekly_emails" > > and everything''s nice and clear. > > > > On 3/24/06, Robby Russell <robby.lists@planetargon.com> wrote: > > On Fri, 2006-03-24 at 12:58 +0200, Alder Green wrote: > > > Hi > > > > > > I know Ruby well, so I''ll probably just use it. Note that I''d still be > > > using parts of Rails'' MVC, in particular the Models. Mikkel Bruun > > > suggested it would be possible to accomplish through script/runner. If > > > that''s indeed the case, I could schedule script/runner runs with with > > > cron (cron is available on shared hosting solutions, right?) and > > > there''s no reason not to use Rails and my favorite language, Ruby :) > > > > Cron + script/runner is perfect for this... and so are scheduled rake > > tasks. > > > > > > -Robby > > > > -- > > > /************************************************************** > > * Robby Russell, Founder & Executive Director * > > * PLANET ARGON, LLC | www.planetargon.com * > > * Ruby on Rails Development, Consulting, and Hosting * > > * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * > > * blog: www.robbyonrails.com | book: www.programmingrails.com * > > > ***************************************************************/ > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Michael Smedberg
2006-Mar-26 19:57 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
I did a similar thing, and I''ve been happy with it. I went a little further and collected the relevant tasks in helper functions. For instance, I might want to run Run.cleanup_db and Run.expire_sessionsfrequently, but Run.send_weekly_emails and Run.generate_statistics only weekly. I''d make helper functions like: def self.frequent_tasks cleanup_db expire_sessions end def self.weekly_tasks send_weekly_emails generate_statistics end This way, when I change the frequent or weekly tasks, I don''t need to change my cron jobs. I can just change my source, update the source on the servers, and I''m good to go. Of course, the same thing could be done with shell scripts, but keeping this all in the code makes update really easy, and it''s portable. On 3/24/06, Brian Hogan <bphogan@gmail.com> wrote:> > +1 on script/runner. > > My solution for a recent project was to make a model (non-active-record) > that has class methods for all of the things I want to run command-line. > > class Run > def self.cleanup_db > > end > > def self.send_weekly_emails > > end > > end > > So then I can just do > ruby script/runner "Run.send_weekly_emails" > > and everything''s nice and clear. > > > > On 3/24/06, Robby Russell <robby.lists@planetargon.com> wrote: > > > > On Fri, 2006-03-24 at 12:58 +0200, Alder Green wrote: > > > Hi > > > > > > I know Ruby well, so I''ll probably just use it. Note that I''d still be > > > using parts of Rails'' MVC, in particular the Models. Mikkel Bruun > > > suggested it would be possible to accomplish through script/runner. If > > > that''s indeed the case, I could schedule script/runner runs with with > > > cron (cron is available on shared hosting solutions, right?) and > > > there''s no reason not to use Rails and my favorite language, Ruby :) > > > > Cron + script/runner is perfect for this... and so are scheduled rake > > tasks. > > > > > > -Robby > > > > -- > > /************************************************************** > > * Robby Russell, Founder & Executive Director * > > * PLANET ARGON, LLC | www.planetargon.com * > > * Ruby on Rails Development, Consulting, and Hosting * > > * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * > > * blog: www.robbyonrails.com | book: www.programmingrails.com * > > ***************************************************************/ > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060326/9a1aa5d0/attachment.html
Giles Bowkett
2006-Mar-26 21:43 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
I''m curious about Rails cron -- have people had good results with it? Better than regular cron or script/runner in a cron job? On 3/26/06, Michael Smedberg <smedberg@gmail.com> wrote:> I did a similar thing, and I''ve been happy with it. I went a little further > and collected the relevant tasks in helper functions. > > For instance, I might want to run Run.cleanup_db and Run.expire_sessions > frequently, but Run.send_weekly_emails and Run.generate_statistics only > weekly. I''d make helper functions like: > > def self.frequent_tasks > cleanup_db > expire_sessions > end > > def self.weekly_tasks > send_weekly_emails > generate_statistics > end > > This way, when I change the frequent or weekly tasks, I don''t need to > change my cron jobs. I can just change my source, update the source on the > servers, and I''m good to go. Of course, the same thing could be done with > shell scripts, but keeping this all in the code makes update really easy, > and it''s portable. > > > On 3/24/06, Brian Hogan <bphogan@gmail.com> wrote: > > > > +1 on script/runner. > > > > My solution for a recent project was to make a model (non-active-record) > that has class methods for all of the things I want to run command-line. > > > > class Run > > def self.cleanup_db > > > > end > > > > def self.send_weekly_emails > > > > end > > > > end > > > > So then I can just do > > ruby script/runner "Run.send_weekly_emails" > > > > and everything''s nice and clear. > > > > > > > > > > On 3/24/06, Robby Russell <robby.lists@planetargon.com> wrote: > > > On Fri, 2006-03-24 at 12:58 +0200, Alder Green wrote: > > > > Hi > > > > > > > > I know Ruby well, so I''ll probably just use it. Note that I''d still be > > > > using parts of Rails'' MVC, in particular the Models. Mikkel Bruun > > > > suggested it would be possible to accomplish through script/runner. If > > > > that''s indeed the case, I could schedule script/runner runs with with > > > > cron (cron is available on shared hosting solutions, right?) and > > > > there''s no reason not to use Rails and my favorite language, Ruby :) > > > > > > Cron + script/runner is perfect for this... and so are scheduled rake > > > tasks. > > > > > > > > > -Robby > > > > > > -- > > > > /************************************************************** > > > * Robby Russell, Founder & Executive Director * > > > * PLANET ARGON, LLC | www.planetargon.com * > > > * Ruby on Rails Development, Consulting, and Hosting * > > > * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * > > > * blog: www.robbyonrails.com | book: www.programmingrails.com * > > > > ***************************************************************/ > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Tom Mornini
2006-Mar-27 03:56 UTC
[Rails] Running Rails tasks by schedule, instead of an HTTP request.
The advantage is that the timed event is stored in your application. I have nothing against cron itself, and there are ways to get many of the same advantages rails_cron gives via system setup scripts, etc. However, using rails_cron should be cross platform and allow you to express the entire application from within the Rails environment without relying on external scheduling tools. -- -- Tom Mornini On Mar 26, 2006, at 1:43 PM, Giles Bowkett wrote:> I''m curious about Rails cron -- have people had good results with it? > Better than regular cron or script/runner in a cron job? > > On 3/26/06, Michael Smedberg <smedberg@gmail.com> wrote: >> I did a similar thing, and I''ve been happy with it. I went a >> little further >> and collected the relevant tasks in helper functions. >> >> For instance, I might want to run Run.cleanup_db and >> Run.expire_sessions >> frequently, but Run.send_weekly_emails and Run.generate_statistics >> only >> weekly. I''d make helper functions like: >> >> def self.frequent_tasks >> cleanup_db >> expire_sessions >> end >> >> def self.weekly_tasks >> send_weekly_emails >> generate_statistics >> end >> >> This way, when I change the frequent or weekly tasks, I don''t >> need to >> change my cron jobs. I can just change my source, update the >> source on the >> servers, and I''m good to go. Of course, the same thing could be >> done with >> shell scripts, but keeping this all in the code makes update >> really easy, >> and it''s portable. >> >> >> On 3/24/06, Brian Hogan <bphogan@gmail.com> wrote: >>> >>> +1 on script/runner. >>> >>> My solution for a recent project was to make a model (non-active- >>> record) >> that has class methods for all of the things I want to run command- >> line. >>> >>> class Run >>> def self.cleanup_db >>> >>> end >>> >>> def self.send_weekly_emails >>> >>> end >>> >>> end >>> >>> So then I can just do >>> ruby script/runner "Run.send_weekly_emails" >>> >>> and everything''s nice and clear. >>> >>> >>> >>> >>> On 3/24/06, Robby Russell <robby.lists@planetargon.com> wrote: >>>> On Fri, 2006-03-24 at 12:58 +0200, Alder Green wrote: >>>>> Hi >>>>> >>>>> I know Ruby well, so I''ll probably just use it. Note that I''d >>>>> still be >>>>> using parts of Rails'' MVC, in particular the Models. Mikkel Bruun >>>>> suggested it would be possible to accomplish through script/ >>>>> runner. If >>>>> that''s indeed the case, I could schedule script/runner runs >>>>> with with >>>>> cron (cron is available on shared hosting solutions, right?) and >>>>> there''s no reason not to use Rails and my favorite language, >>>>> Ruby :) >>>> >>>> Cron + script/runner is perfect for this... and so are scheduled >>>> rake >>>> tasks. >>>> >>>> >>>> -Robby >>>> >>>> -- >>>> >> /************************************************************** >>>> * Robby Russell, Founder & Executive Director * >>>> * PLANET ARGON, LLC | www.planetargon.com * >>>> * Ruby on Rails Development, Consulting, and Hosting * >>>> * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * >>>> * blog: www.robbyonrails.com | book: www.programmingrails.com * >>>> >> ***************************************************************/ >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails@lists.rubyonrails.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails