What is the best way to implement a ''Down for Maintenance'' page across your Rails app? Ideally I would like to have a button in my admin section that toggles the display of a ''currently under maintenance'' page to every public request to the app (possibly with some dynamic content like estimated down-time) except for: - - requests from a specified IP address (so I could access the live site from while developing/debugging and use the site as normal while everyone else sees the ''down'' page) - the admin section (so I''m not locked out!) What is the best strategy to achieve this? I''ve been looking for stuff online but it''s fairly thin on the ground concerning this idea - by which I mean I can''t seem to find it :0) Any ideas or advice very gratefully received, Chris -- Posted via http://www.ruby-forum.com/.
Joshua Schairbaum
2006-Jun-15 17:30 UTC
[Rails] Best Approach to a ''Down for Maintenance'' Page?
Chris, I''d highly suggest you take a look at some of the Capistrano tasks for this. For example, you could take your site down to the public and still be able to do some administrative things, such as access the console and such. I''m thinking specifically of the ''disable_web'' task. It can be found here: http://manuals.rubyonrails.org/read/chapter/103#page279 Josh -- Posted with http://DevLists.com. Sign up and save your mailbox.
subimage interactive
2006-Jun-15 19:09 UTC
[Rails] Best Approach to a ''Down for Maintenance'' Page?
The ghetto/bootleg way to do it is just add a file called index.html to your public directory... On 15 Jun 2006 17:30:36 -0000, Joshua Schairbaum < devlists-rubyonrails@devlists.com> wrote:> > Chris, > > I''d highly suggest you take a look at some of the Capistrano tasks for > this. For example, you could take your site down to the public and > still be able to do some administrative things, such as access the > console and such. > > I''m thinking specifically of the ''disable_web'' task. It can be found > here: > http://manuals.rubyonrails.org/read/chapter/103#page279 > > Josh > > > > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- seth at subimage interactive http://www.subimage.com/sublog/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/57d9d8a4/attachment.html
> I''d highly suggest you take a look at some of the Capistrano tasks for > this. For example, you could take your site down to the public and > still be able to do some administrative things, such as access the > console and such. > > I''m thinking specifically of the ''disable_web'' task. It can be found > here: > http://manuals.rubyonrails.org/read/chapter/103#page279Josh, Thanks for the link, and that''s certainly something I will investigate more, the problem with that is it seems to be dependent upon using Apache, whereas I am using Lighttpd (and would like to continue using if possible). Therefore I was hoping to develop a strategy/receipe that would just involve a basic rails app without recourse to plugins, gems or external scripts etc. Will go and do some reading on capistrano though, might give some clues how to implement my own version. Submimage, Whilst this would work it wouldn''t block visitors with bookmarked links, or those following links from search engines - but yes it would work to a degree! Thanks guys, Chris PS - Anyone else got any other suggestions? -- Posted via http://www.ruby-forum.com/.
Steve Koppelman
2006-Jun-15 19:32 UTC
[Rails] Re: Best Approach to a ''Down for Maintenance'' Page?
Capistrano is webserver-agnostic. You might(?) have to modify the recipe to run lighttpd startup and shutdown commands, but Capistrano''s your friend either way as long as you''re serving off something Unixy. Another way to redirect things might be a different routres.rb file for downtime, with pretty much everything mapped to your "Sorry" page. Capistrano would still be a super way to automate switching it in and out. Chris wrote:>> I''d highly suggest you take a look at some of the Capistrano tasks for >> this. For example, you could take your site down to the public and >> still be able to do some administrative things, such as access the >> console and such. >> >> I''m thinking specifically of the ''disable_web'' task. It can be found >> here: >> http://manuals.rubyonrails.org/read/chapter/103#page279 > > Josh, > Thanks for the link, and that''s certainly something I will investigate > more, the problem with that is it seems to be dependent upon using > Apache, whereas I am using Lighttpd (and would like to continue using if > possible). Therefore I was hoping to develop a strategy/receipe that > would just involve a basic rails app without recourse to plugins, gems > or external scripts etc. > > Will go and do some reading on capistrano though, might give some clues > how to implement my own version. > > > Submimage, > Whilst this would work it wouldn''t block visitors with bookmarked links, > or those following links from search engines - but yes it would work to > a degree! > > > Thanks guys, > Chris > > PS - Anyone else got any other suggestions?-- Posted via http://www.ruby-forum.com/.
Curtis
2006-Jun-15 19:38 UTC
[Rails] Re: Best Approach to a ''Down for Maintenance'' Page?
On 6/15/06, Chris <chris@firegoby.com> wrote:> PS - Anyone else got any other suggestions?Just something I pulled out of my ... well ... Regardless, what would be the downsides/upsides to just setting a flag in a "configs" table (or even hardcoded if you''re worried about speed) and using an application "before_filter" to redirect based upon whatever conditions? before_filter :application_mode_redirect def application_mode_redirect #test conditions #redirect to "currently down" notification if appropriate #pass-through for admins end I doubt the speed hit would be too bad... If so you could "cache" the check condition and only check it once every few minutes or something.... :: shrug :: -Curtis
Ezra Zygmuntowicz
2006-Jun-15 19:39 UTC
[Rails] Re: Best Approach to a ''Down for Maintenance'' Page?
> > Thanks guys, > Chris > > PS - Anyone else got any other suggestions? >Chris- You might be able to put a conditional before_filter in application.rb. Maybe something like this: before_filter :check_for_maintenence protected def check_for_maintenence if File.exist? "#{RAILS_ROOT}/maintenence.html" return render( :file => "#{RAILS_ROOT}/maintenence.html") unless current_user.is_admin? end end Of course that means that every hit to your app will always check for the maintenence.html page. File.exist? is pretty fast thouhg. Certainly faster then a database lookup. Then you would just need to make sure you have a current_user object setup and an is_admin? method to telkl whether the user is an admin or not. This way everyone else that hits the app will get the maintenence page expect the admin who will have normal access. Cheers- -Ezra
Charlie Bowman
2006-Jun-15 20:23 UTC
[Rails] Re: Best Approach to a ''Down for Maintenance'' Page?
Couldn''t you just add something in your routes that would make all requests go to the temporarily down page? Then comment this out when you wanted the site back live? On Thu, 2006-06-15 at 12:39 -0700, Ezra Zygmuntowicz wrote:> > > > Thanks guys, > > Chris > > > > PS - Anyone else got any other suggestions? > > > > > Chris- > > You might be able to put a conditional before_filter in > application.rb. Maybe something like this: > > > before_filter :check_for_maintenence > > protected > > def check_for_maintenence > if File.exist? "#{RAILS_ROOT}/maintenence.html" > return render( :file => "#{RAILS_ROOT}/maintenence.html") > unless current_user.is_admin? > end > end > > > Of course that means that every hit to your app will always check > for the maintenence.html page. File.exist? is pretty fast thouhg. > Certainly faster then a database lookup. Then you would just need to > make sure you have a current_user object setup and an is_admin? > method to telkl whether the user is an admin or not. This way > everyone else that hits the app will get the maintenence page expect > the admin who will have normal access. > > > Cheers- > -Ezra > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsCharlie Bowman http://www.recentrambles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/619abfb2/attachment.html
Chris
2006-Jun-15 20:48 UTC
[Rails] Re: Re: Best Approach to a ''Down for Maintenance'' Page?
Ezra Zygmuntowicz wrote:> You might be able to put a conditional before_filter in > application.rb. Maybe something like this: > > > before_filter :check_for_maintenence > > protected > > def check_for_maintenence > if File.exist? "#{RAILS_ROOT}/maintenence.html" > return render( :file => "#{RAILS_ROOT}/maintenence.html") > unless current_user.is_admin? > end > end >Curtis & Ezra, Thanks very much to both of you, i think this proves great minds think alike since you both posted at the same time! This method looks like it''ll work a perfectly, I didn''t realise I could do a before_filter on application.rb - there''s an added bonus if using Ezra''s current_user idea since I wouldn''t have to enter my IP, just log in as admin''s equivalent of root and hack away! Though I suppose I would have to design some kind of fail-safe in case I got diconnected and lost my session details. Steve - I''m not all that up on capistrano, though it''s great to know that it''s webserver agnostic, having just learnt how to deploy rails apps the textdrive-by-hand method I''m a little apprehensive about learning another system (despite the amazing power of the thing) - though now I suppose I''ll have to add it to my to-learn list - is Capistrano quickly becoming the de-facto deployment system for rails? is it likely to be incorporated into the core? i.e. is it a ''must-learn'' or more of a ''could-learn''? Thanks to everyone for the awesome response, the community around rails is just fantastic! -- Posted via http://www.ruby-forum.com/.
Curtis
2006-Jun-15 21:11 UTC
[Rails] Re: Re: Best Approach to a ''Down for Maintenance'' Page?
On 6/15/06, Chris <chris@firegoby.com> wrote: Chris, TextDrive supports SVN repositories and Capistrano deployment. I would imagine most of the major RoR hosting companies are doing so. It''s a little more difficult to learn how to use Capistrano if your core development OS is Windows; but there are enough tutorials that you can learn how to use it with your TextDrive account. :) -Curtis P.S. No problem. I''m no expert, but I have fun with RoR. I like to contribute. It''s either that or go flame people on the political forums. And while that''s fun too, it''s a different kind of fun...heehee :: cough ::
Chris
2006-Jun-15 21:26 UTC
[Rails] Re: Re: Re: Best Approach to a ''Down for Maintenance'' Page?
Curtis Spendlove wrote:> TextDrive supports SVN repositories and Capistrano deployment. I > would imagine most of the major RoR hosting companies are doing so. > It''s a little more difficult to learn how to use Capistrano if your > core development OS is Windows; but there are enough tutorials that > you can learn how to use it with your TextDrive account. :) >yeah that was one of my fears, I''m stuck on windows unfortunately, I''m planning to move to mac on my next upgrade but was holding off until the Rev. B Intel laptops are out, at the current rate of annoyances with windows though I think I might get one of those mac mini things in the mean time (I used to run linux but the lack of photoshop was killin'' me!)> > P.S. No problem. I''m no expert, but I have fun with RoR. I like to > contribute. It''s either that or go flame people on the political > forums. And while that''s fun too, it''s a different kind of > fun...heehee :: cough ::Haha, funnily enough I *just* came from yelling on a political blog! A different kind of fun for sure but great after a day battling IE''s CSS implementation! Thanks again :0) -- Posted via http://www.ruby-forum.com/.
Michael Daines
2006-Jun-15 22:53 UTC
[Rails] Re: Best Approach to a ''Down for Maintenance'' Page?
> You might be able to put a conditional before_filter in > application.rb.I think this can also be done in lighttpd. See the "Power Magnet" here: http://lighttpd.net/documentation/cml.html#power-magnet ...which is similar to that rewrite rule in Apache. This way, you bypass your Rails app if maintenance is being performed. -- Michael Daines http://www.mdaines.com
Chris
2006-Jun-15 23:13 UTC
[Rails] Re: Re: Best Approach to a ''Down for Maintenance'' Page?
Michael Daines wrote:> I think this can also be done in lighttpd. See the "Power Magnet" here: > > http://lighttpd.net/documentation/cml.html#power-magnet > > ...which is similar to that rewrite rule in Apache. This way, you > bypass your Rails app if maintenance is being performed.Oh wow, thanks Michael, that''s very useful indeed (not just for maintenance but also as per their example of serving up thumbnails etc) - this looks great Only trouble is now which method to use, the before_filter allows greater flexibility I would imagine but the lighttpd should be quicker, and it''s very easy to implement (which is always nice!) Thanks very much Michael, I think I''m going to play around with some test apps tomorrow and see what happens, depending upon how I get on I might write up the results for a mini-guide for any future people with the same issue. Cheers all :0) -- Posted via http://www.ruby-forum.com/.
Just Someone
2006-Jun-16 00:39 UTC
[Rails] Re: Re: Best Approach to a ''Down for Maintenance'' Page?
Using the magnet from lighttpd will require you to have the LUA scripting language installed. It''s not always included in default configs, so you might want to compile it yourself in. I''m using a capistrano recipe described on my blog: http://devblog.famundo.com/articles/2006/03/06/capistrano-aka-switchtower-and-security It''s more secure than the disable web method, as the deploying user doesn''t write anything into the server config. I''m also using rewrite and aliasing in lighty to serve other static info as the performance is just uncomparable to serving it with rails. You can see that on my blog as well. Last and not directly related, if you need SSL on lighty read my blog post about it. The documentation is missing some stuff: http://devblog.famundo.com/articles/2006/04/30/lighttpd-with-ssl Bye, Guy On 6/15/06, Chris <chris@firegoby.com> wrote:> Michael Daines wrote: > > > I think this can also be done in lighttpd. See the "Power Magnet" here: > > > > http://lighttpd.net/documentation/cml.html#power-magnet > > > > ...which is similar to that rewrite rule in Apache. This way, you > > bypass your Rails app if maintenance is being performed. > > Oh wow, thanks Michael, that''s very useful indeed (not just for > maintenance but also as per their example of serving up thumbnails etc) > - this looks great > > Only trouble is now which method to use, the before_filter allows > greater flexibility I would imagine but the lighttpd should be quicker, > and it''s very easy to implement (which is always nice!) > > Thanks very much Michael, I think I''m going to play around with some > test apps tomorrow and see what happens, depending upon how I get on I > might write up the results for a mini-guide for any future people with > the same issue. > > Cheers all :0) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Family management on rails: http://www.famundo.com - coming soon! My development related blog: http://devblog.famundo.com