potential fix for #1305

This commit is contained in:
Albert Yi
2013-04-14 18:22:25 -07:00
parent 96a468b51a
commit f5b0f856d6
4 changed files with 21 additions and 14 deletions

View File

@@ -1,7 +1,9 @@
class ApiCacheGenerator class ApiCacheGenerator
def generate_tag_cache def generate_tag_cache
File.open("#{Rails.root}/public/cache/tags.json", "w") do |f| FileUtils.mkdir_p("/var/www/danbooru2/shared/system/cache")
File.open("/var/www/danbooru2/shared/system/cache/tags.json", "w") do |f|
f.print("[") f.print("[")
Tag.without_timeout do
Tag.find_each do |tag| Tag.find_each do |tag|
next unless tag.post_count > 0 next unless tag.post_count > 0
hash = { hash = {
@@ -14,6 +16,7 @@ class ApiCacheGenerator
f.print(hash.to_json) f.print(hash.to_json)
f.print(", ") f.print(", ")
end end
end
f.seek(-2, IO::SEEK_END) f.seek(-2, IO::SEEK_END)
f.print("]\n") f.print("]\n")
end end

View File

@@ -2,7 +2,7 @@ class DailyMaintenance
def run def run
ActiveRecord::Base.connection.execute("set statement_timeout = 0") ActiveRecord::Base.connection.execute("set statement_timeout = 0")
PostPruner.new.prune! PostPruner.new.prune!
# TagPruner.new.prune! TagPruner.new.prune!
Upload.delete_all(['created_at < ?', 1.day.ago]) Upload.delete_all(['created_at < ?', 1.day.ago])
ModAction.delete_all(['created_at < ?', 3.days.ago]) ModAction.delete_all(['created_at < ?', 3.days.ago])
Delayed::Job.delete_all(['created_at < ?', 1.day.ago]) Delayed::Job.delete_all(['created_at < ?', 1.day.ago])

View File

@@ -1,7 +1,6 @@
class TagPruner class TagPruner
def prune! def prune!
Tag.without_timeout do Tag.without_timeout do
Tag.destroy_all(["post_count <= 0 and name like '%%:%%'"])
end end
end end
end end

View File

@@ -57,6 +57,11 @@ namespace :data do
run "rm -f #{release_path}/public/images/advertisements" run "rm -f #{release_path}/public/images/advertisements"
run "ln -s #{deploy_to}/shared/advertisements #{release_path}/public/images/advertisements" run "ln -s #{deploy_to}/shared/advertisements #{release_path}/public/images/advertisements"
run "mkdir -p #{release_path}/public/cache"
run "mkdir -p #{deploy_to}/shared/system/cache"
run "touch #{deploy_to}/shared/system/cache/tags.json"
run "ln -s #{deploy_to}/shared/system/cache/tags.json #{release_path}/public/cache/tags.json"
end end
end end