add cronjob for syncing files

This commit is contained in:
r888888888 2018-10-04 01:51:42 -07:00
parent 25c0c8884c
commit abbe181de6
2 changed files with 19 additions and 1 deletions

View File

@ -1,4 +1,18 @@
class DailyMaintenance
def hourly
sm = Danbooru.config.storage_manager
Post.where("id >= ? and created_at > ?", 3275713, 10.minutes.ago).find_each do |post|
file_path = sm.file_path(post, post.file_ext, :original)
sm.store_file(File.open(file_path, "rb"), post, :original)
preview_path = sm.file_path(post, post.file_ext, :preview)
sm.store_file(File.open(preview_path, "rb"), post, :preview)
if post.has_large?
sample_path = sm.file_path(post, post.file_ext, :large)
sm.store_file(File.open(sample_path, "rb"), post, :large)
end
end
end
def run
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
PostPruner.new.prune!

View File

@ -1,6 +1,10 @@
set :output, "/var/log/whenever.log"
#env "MAILTO", "webmaster@danbooru.donmai.us"
every 10.minutes do
runner "DailyMaintenance.new.hourly"
end
every 1.hour do
runner "UploadErrorChecker.new.check!"
end
@ -14,7 +18,7 @@ every 1.day do
end
every 1.day, :at => "1:00 am" do
command "psql --set statement_timeout=0 -hdbserver -c \"vacuum analyze;\" danbooru2"
command "psql --set statement_timeout=0 -h inuyama -c \"vacuum analyze;\" danbooru2"
end
every 1.week, :at => "1:30 am" do