forked from e621ng/e621ng
[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:
parent
598d1f289a
commit
934c8e3b87
1
Gemfile
1
Gemfile
@ -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"
|
||||
|
@ -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
|
||||
|
3
Procfile
3
Procfile
@ -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
|
||||
|
@ -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
|
||||
|
29
bin/whenever
29
bin/whenever
@ -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")
|
@ -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")
|
@ -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
|
@ -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
|
||||
|
4
docker/cron_tasks/daily/daily_maintenance.sh
Executable file
4
docker/cron_tasks/daily/daily_maintenance.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
echo "Running daily maintenance"
|
||||
cd /app && bundle exec rake maintenance:daily
|
||||
echo "Finished daily maintenance"
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user