I run Radiant on Passenger and I was wondering if there was a way to
have the home page of a site always cached.
When there have been no visitors to a site for about a day, it often
takes the sever more than 20 seconds to respond to a request for a page.
Ben M. wrote:
I run Radiant on Passenger and I was wondering if there was a way to
have the home page of a site always cached.
When there have been no visitors to a site for about a day, it often
takes the sever more than 20 seconds to respond to a request for a page.
I think that is probably when it recreates the whole page and loads
Rails, etc. Does the home page change a lot? If it doesn’t change,
would it make sense to create a static version of it?
I believe that there is a way to change the caching settings, but sorry
I don’t have that available off-hand.
There are these items stored in my email folder:
Cheers,
Mohit.
1/22/2009 | 11:52 PM.
On Jan 22, 2009, at 10:50 AM, Ben M. wrote:
I run Radiant on Passenger and I was wondering if there was a way to
have the home page of a site always cached.
When there have been no visitors to a site for about a day, it often
takes the sever more than 20 seconds to respond to a request for a
page.
You could set the cache timeout to 2.days, or something of that nature.
–
John L.
http://wiseheartdesign.com
You could fetch your homepage in a regular intervall via a cronjob.
E.g. wget -r -nd --delete-after http://yoursite.com
/simon
On Thu, 22 Jan 2009 16:50:12 +0100
To force Passenger to stay running, you can set PassengerPoolIdleTime to
some insanely huge value. They recommend 2 x TimeBetweenRequests. So
if it’s a day between requests, set the value to 2 * 24 * 60 * 60 or
172800.
Sean
I haven’t tried it out yet with 0.7 yet at all. Are you using
passenger to test or mongrel. In the past I have had problems with
uploading and passenger in the development environment, but hitting
submit again uploads it when it hangs. This does not happen in
production and has been noted on the Paperclip mailing list.
Hope that helps a bit.
Keith
I was wondering if anyone is using paperclipped with 0.7.0rc2. It
seems to be stalling out on uploading an asset. This could easily be
something unrelated to 0.7.0rc2. If anyone knows anything about
what’s going on I’d greatly appreciate the help.
Steven
On Jan 22, 2009, at 11:18 AM, Steven S. wrote:
I was wondering if anyone is using paperclipped with 0.7.0rc2. It
seems to be stalling out on uploading an asset. This could easily
be something unrelated to 0.7.0rc2. If anyone knows anything about
what’s going on I’d greatly appreciate the help.
Would the asset happen to be a non-image file like a PDF or Word
document? I couldn’t get past this problem, hence I went with
page_attachments, but others on this list have gotten it working.
Jose
…
Jose Hales-Garcia
UCLA Department of Statistics
[email protected]
Well I’m using mongrel in a production environment. It was hanging
when I upload an image but I shut down a few processes and it seems to
be going through. Now when I try to remove an asset I get an
Application error. If i hit refresh three or four time it does clear
itself up and remove the asset. I’m also using Setting so I wonder if
there could be a problem with that.
On Thu, Jan 22, 2009 at 6:53 PM, Benny D.
<[email protected]
wrote:
named route that no longer exists.
I also made it skip mimetype validation altogether if you set
Radiant::Config[“assets.skip_filetype_validation”] = true
see the github network;
Network Graph · kbingman/paperclipped · GitHub
That is great information, Benny. When I move up to 0.7, I’ll definitely
need this. Thanks.
~Nate
On Thu, Jan 22, 2009 at 1:39 PM, Jose Hales-Garcia
[email protected]wrote:
I couldn’t get past this problem, hence I went with page_attachments, but
others on this list have gotten it working.
It works with other mime-types, but you have to specify them using the
Settings extension. You may also need to pare (sp?) down the number of
mime-types listed as well, because sometimes that field in settings is
truncated. It’s really no big deal, just take out the mime-types you’ll
never use (and there are a few) and replace them with the ones you need.
I have no problems using paperclipped, but I am using it with 0.6.9,
though.
~Nate
Sean C. wrote:
To force Passenger to stay running, you can set PassengerPoolIdleTime to
some insanely huge value. They recommend 2 x TimeBetweenRequests. So
if it’s a day between requests, set the value to 2 * 24 * 60 * 60 or
172800.
Thanks for all the suggestions!
I decided to go with a cron job so that I wouldn’t have to guess about
what to change the cache or server settings to.
However, it wasn’t working properly – still had the long delay – while
I was using “> /dev/null” for some reason. So I simply removed that part
and stuck with the “-s” flag, and now the page loads up immediately.
Sounds like paperclip should use FileUtils.rm_rf instead of rm_dir.
Sean
Steven,
Thanks for the detailed stacktrace. This is interesting, it really
sounds like a difference between Solaris and the Mac. If I have a
minute today I’ll look at the paperclipped source and see if I can
figure out what’s going on. It’s acting like the extension is trying
to delete the directory before all the files have been removed. Maybe
Solaris throws an EEXIST when an rmdir is attempted on a non-empty
directory but Linux/Mac throws something else, or nothing.
Unfortunately I don’t have access to a Solaris machine to test on.
Solaris has a reputation for being “different”–most of the Mac and
Linux command line tools and libraries are pretty similar, but the
Solaris libraries have been their own forever. The first thing I
would do when encountering a Solaris box that I was responsible for
was to install most of the Gnu suite.
–cro
Steven,
Also, can you send us a server log excerpt for this delete?
–cro
On Jan 28, 2009, at 11:49 AM, Sean C. wrote:
Sounds like paperclip should use FileUtils.rm_rf instead of rm_dir.
It doesn’t, at least if it is the same as the one I have installed.
Here’s the code:
def flush_deletes #:nodoc:
logger.info("[paperclip] Deleting files for #{name}")
@queued_for_delete.each do |path|
begin
logger.info("[paperclip] -> #{path}")
FileUtils.rm(path) if File.exist?(path)
rescue Errno::ENOENT => e
# ignore file-not-found, let everything else pass
end
end
@queued_for_delete = []
end
end
File.exist? returns true for files and directories. But unless I have
an old version of paperclipped that doesn’t call FileUtils.rm, the
Ruby docs say specifically that FileUtils.rm does not remove
directories. And to be really safe, it should use
FileUtils.remove_entry_secure.
Steven, you might try a quick patch and change FileUtils.rm to
FileUtils.remove_entry_secure (or FileUtils.rm_rf like Sean suggests
if you are not terribly worried about security) in vendor/extensions/
paperclipped/vendor/plugins/paperclip/lib/paperclip/storage.rb
–cro
Thank you for looking into this. I tried both yours and Sean quick fix
and neither helped.
here is the full stack
Parameters: {“action”=>“remove”,
“authenticity_token”=>“b3c11c1f1191103da344cae2345c5beb9a7654d”,
“id”=>“11”, “controller”=>“assets”}
[paperclip] Paperclip attachment asset on Asset initialized.
[paperclip] Deleting attachments.
[paperclip] Queueing the existing files for asset for deletion.
[paperclip] Deleting files for asset
[paperclip] -> /users/home/…/web/public/assets/11/testimage.jpg
Errno::EEXIST (File exists - /users/home/…/web/public/assets/11):
/usr/local/lib/ruby/1.8/fileutils.rb:264:in rmdir' /usr/local/lib/ruby/1.8/fileutils.rb:264:in
rmdir’
/usr/local/lib/ruby/1.8/fileutils.rb:263:in each' /usr/local/lib/ruby/1.8/fileutils.rb:263:in
rmdir’
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/
paperclip/storage.rb:62:in flush_deletes' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip/storage.rb:52:in
each’
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/
paperclip/storage.rb:52:in flush_deletes' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip.rb:301:in
send’
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/
paperclip.rb:301:in destroy_attached_files' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip.rb:286:in
each_attachment’
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/
paperclip.rb:285:in each' /vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/ paperclip.rb:285:in
each_attachment’
/vendor/extensions/paperclipped/vendor/plugins/paperclip/lib/
paperclip.rb:299:in destroy_attached_files' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:173:in
send’
/vendor/rails/activerecord/lib/…/…/activesupport/lib/
active_support/callbacks.rb:173:in evaluate_method' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:161:in
call’
/vendor/rails/activerecord/lib/…/…/activesupport/lib/
active_support/callbacks.rb:93:in run' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:92:in
each’
/vendor/rails/activerecord/lib/…/…/activesupport/lib/
active_support/callbacks.rb:92:in send' /vendor/rails/activerecord/lib/../../activesupport/lib/ active_support/callbacks.rb:92:in
run’
/vendor/rails/activerecord/lib/…/…/activesupport/lib/
active_support/callbacks.rb:272:in run_callbacks' /vendor/rails/activerecord/lib/active_record/callbacks.rb:298:in
callback’
/vendor/rails/activerecord/lib/active_record/callbacks.rb:288:in
destroy_without_transactions' /vendor/rails/activerecord/lib/active_record/transactions.rb: 102:in
destroy’
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:66:in transaction' /vendor/rails/activerecord/lib/active_record/transactions.rb: 79:in
transaction’
/vendor/rails/activerecord/lib/active_record/transactions.rb:
98:in transaction' /vendor/rails/activerecord/lib/active_record/transactions.rb: 102:in
destroy’
/vendor/extensions/paperclipped/app/controllers/
assets_controller.rb:110:in remove' /vendor/rails/actionpack/lib/action_controller/base.rb:1166:in
send’
/vendor/rails/actionpack/lib/action_controller/base.rb:1166:in
perform_action_without_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:579:in
call_filters’
/vendor/rails/actionpack/lib/action_controller/filters.rb:572:in
perform_action_without_benchmark' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 68:in
perform_action_without_rescue’
/usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 68:in
perform_action_without_rescue’
/vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in
perform_action_without_caching' /vendor/rails/actionpack/lib/action_controller/caching/ sql_cache.rb:13:in
perform_action’
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/query_cache.rb:33:in cache' /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in
cache’
/vendor/rails/actionpack/lib/action_controller/caching/
sql_cache.rb:12:in perform_action' /vendor/rails/actionpack/lib/action_controller/base.rb:529:in
send’
/vendor/rails/actionpack/lib/action_controller/base.rb:529:in
process_without_filters' /vendor/rails/actionpack/lib/action_controller/filters.rb:568:in
process_without_session_management_support’
/vendor/rails/actionpack/lib/action_controller/
session_management.rb:130:in sass_old_process' /vendor/plugins/haml/lib/sass/plugin/rails.rb:19:in
process’
/vendor/rails/actionpack/lib/action_controller/base.rb:389:in
process' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb: 149:in
handle_request’
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:
107:in dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb: 104:in
synchronize’
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:
104:in dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb: 120:in
dispatch_cgi’
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:
35:in dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel/rails.rb:76:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel/rails.rb:74:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel/rails.rb:74:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel.rb:159:in process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:158:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel.rb:158:in process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:285:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel.rb:285:in initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:285:in
new’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel.rb:285:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:268:in
initialize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel.rb:268:in new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel.rb:268:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel/configurator.rb:282:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/ mongrel/configurator.rb:281:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel/configurator.rb:281:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails: 133:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/
mongrel/command.rb:212:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails: 286 /usr/local/bin/mongrel_rails:19:in
load’
/usr/local/bin/mongrel_rails:19
Rendering /users/home/…/web/public/500.html (500 Internal Server
Error)
This is what the access_log said:
“POST /admin/assets/14/remove HTTP/1.1” 500 256 “http://…/admin/
assets/14/remove”
The error_log or the mongrel.log said nothing at all about it.
I’ve resolved the problem or at least it works okay now.
My code looked like this:
def flush_deletes #:nodoc:
logger.info("[paperclip] Deleting files for #{name}")
@queued_for_delete.each do |path|
begin
logger.info("[paperclip] -> #{path}")
FileUtils.rm(path) if File.exist?(path)
rescue Errno::ENOENT => e
# ignore file-not-found, let everything else pass
end
begin
while(true)
path = File.dirname(path)
FileUtils.rmdir(path)
end
rescue Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL,
Errno::ENOTDIR
# Stop trying to remove parent directories
end
end
@queued_for_delete = []
end
When I compared it to Oldham’s code I noticed that mine had this extra:
begin
while(true)
path = File.dirname(path)
FileUtils.rmdir(path)
end
rescue Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL,
Errno::ENOTDIR
# Stop trying to remove parent directories
end
Once I removed it the extension worked without error.
Thanks for your help.
Steven