[Docker] Run daily maintenance

Remove whenever, it's not used in prod. Prod uses systemd timers.
This executes the daily task on container startup. My PC isn't going to
run when this would execute 99% of the time.
This commit is contained in:
Earlopain 2022-12-09 18:16:53 +01:00
parent 598d1f289a
commit 934c8e3b87
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
10 changed files with 7 additions and 96 deletions

View File

@ -7,7 +7,6 @@ gem "pg"
gem "dalli", :platforms => :ruby
gem "simple_form"
gem 'active_model_serializers', '~> 0.10.0'
gem "whenever", :require => false
gem "sanitize"
gem 'ruby-vips'
gem 'diff-lcs', :require => "diff/lcs/array"

View File

@ -98,7 +98,6 @@ GEM
byebug (11.1.3)
case_transform (0.2)
activesupport
chronic (0.10.2)
cityhash (0.9.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
@ -386,8 +385,6 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
yard (0.9.28)
webrick (~> 1.7.0)
zeitwerk (2.6.1)
@ -442,7 +439,6 @@ DEPENDENCIES
unicorn-worker-killer
webmock
webpacker (>= 4.0.x)
whenever
BUNDLED WITH
2.3.12

View File

@ -1,2 +1,3 @@
unicorn: bin/rails server -p 9000 -b 0.0.0.0
server: bin/rails server -p 9000 -b 0.0.0.0
jobs: bundle exec sidekiq -c 1 -q low_prio -q tags -q default -q high_prio -q video
cron: run-parts /etc/periodic/daily && crond -f

View File

@ -14,10 +14,6 @@ module Maintenance
ignoring_exceptions { StatsUpdater.run! }
end
def weekly
return if Danbooru.config.readonly_mode?
end
def ignoring_exceptions(&block)
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
yield

View File

@ -1,29 +0,0 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'whenever' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path("../bundle", __FILE__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("whenever", "whenever")

View File

@ -1,29 +0,0 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'wheneverize' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path("../bundle", __FILE__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("whenever", "wheneverize")

View File

@ -1,18 +0,0 @@
set :output, "/var/log/whenever.log"
#env "MAILTO", "webmaster@danbooru.donmai.us"
every 1.hour do
rake "maintenance:hourly"
end
every 1.day do
rake "maintenance:daily"
end
every 1.day, :at => "1:00 am" do
command "psql --set statement_timeout=0 -h inuyama -c \"vacuum analyze;\" danbooru2"
end
every 1.week, :at => "1:30 am" do
rake "maintenance:weekly"
end

View File

@ -33,6 +33,7 @@ services:
- node_modules:/app/node_modules
- public_packs:/app/public/packs
- post_data:/app/public/data
- ./docker/cron_tasks/daily:/etc/periodic/daily
environment:
<<: *common-env
RAILS_ENV: development

View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
echo "Running daily maintenance"
cd /app && bundle exec rake maintenance:daily
echo "Finished daily maintenance"

View File

@ -1,18 +1,8 @@
require "tasks/newrelic" if defined?(NewRelic)
namespace :maintenance do
desc "Run hourly maintenance jobs"
task hourly: :environment do
Maintenance.hourly
end
desc "Run daily maintenance jobs"
task daily: :environment do
Maintenance.daily
end
desc "Run weekly maintenance jobs"
task weekly: :environment do
Maintenance.weekly
end
end