move cron jobs into good job
This commit is contained in:
parent
9a55d1201d
commit
5229867d4d
1
Gemfile
1
Gemfile
@ -73,7 +73,6 @@ gem "redis", "~> 5.0"
|
||||
gem "rubocop", "~> 1.57"
|
||||
gem "rubocop-erb", "~> 0.3.0"
|
||||
gem "rubocop-rails", "~> 2.22"
|
||||
gem "whenever", "~> 1.0"
|
||||
|
||||
gem "filesize", "~> 0.2.0"
|
||||
|
||||
|
@ -115,7 +115,6 @@ GEM
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
chronic (0.10.2)
|
||||
concurrent-ruby (1.2.2)
|
||||
connection_pool (2.4.1)
|
||||
crass (1.0.6)
|
||||
@ -343,8 +342,6 @@ GEM
|
||||
websocket-driver (0.7.6)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
whenever (1.0.0)
|
||||
chronic (>= 0.6.3)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
zeitwerk (2.6.12)
|
||||
@ -387,7 +384,6 @@ DEPENDENCIES
|
||||
timeout (~> 0.4.1)
|
||||
tzinfo-data
|
||||
web-console
|
||||
whenever (~> 1.0)
|
||||
|
||||
RUBY VERSION
|
||||
ruby 3.2.2p53
|
||||
|
1
Procfile
1
Procfile
@ -1,3 +1,2 @@
|
||||
server: bin/rails server -p 3000 -b 0.0.0.0
|
||||
cron: bundler exec whenever --set environment="$RAILS_ENV" --update-crontab && crond -f
|
||||
jobs: bundle exec good_job start
|
||||
|
@ -1,4 +1,3 @@
|
||||
server: bin/rails server -p 3000 -b 0.0.0.0
|
||||
assets: yarn build --watch
|
||||
cron: bundler exec whenever --set environment="$RAILS_ENV" --update-crontab && crond -f
|
||||
jobs: bundle exec good_job start
|
||||
|
12
app/jobs/e621_exports_job.rb
Normal file
12
app/jobs/e621_exports_job.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class E621ExportsJob < ApplicationJob
|
||||
queue_as :low_priority
|
||||
|
||||
def perform
|
||||
E621.constants.map { |c| E621.const_get(c) }.filter { |c| c < ApplicationRecord }.each do |type|
|
||||
Rails.logger.debug { "Updating #{type}" }
|
||||
type.sync!
|
||||
end
|
||||
E621::Pool.sync_tags!
|
||||
E621PoolImportJob.perform_now
|
||||
end
|
||||
end
|
7
app/jobs/e621_status_update_job.rb
Normal file
7
app/jobs/e621_status_update_job.rb
Normal file
@ -0,0 +1,7 @@
|
||||
class E621StatusUpdateJob < ApplicationJob
|
||||
queue_as :low_priority
|
||||
|
||||
def perform
|
||||
E621StatusUpdater.run
|
||||
end
|
||||
end
|
@ -89,6 +89,17 @@ Rails.application.configure do
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
config.good_job.cron = {
|
||||
e621_status_update: {
|
||||
cron: "* * * * *",
|
||||
class: "E621StatusUpdateJob",
|
||||
},
|
||||
e621_exports: {
|
||||
cron: "50 10 * * *",
|
||||
class: "E621ExportsJob",
|
||||
},
|
||||
}
|
||||
|
||||
# Enable DNS rebinding protection and other `Host` header attacks.
|
||||
# config.hosts = [
|
||||
# "example.com", # Allow requests from example.com
|
||||
|
@ -1,36 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Use this file to easily define all of your cron jobs.
|
||||
#
|
||||
# It's helpful, but not entirely necessary to understand cron before proceeding.
|
||||
# http://en.wikipedia.org/wiki/Cron
|
||||
|
||||
# Example:
|
||||
#
|
||||
# set :output, "/path/to/my/cron_log.log"
|
||||
#
|
||||
# every 2.hours do
|
||||
# command "/usr/bin/some_great_command"
|
||||
# runner "MyModel.some_method"
|
||||
# rake "some:great:rake:task"
|
||||
# end
|
||||
#
|
||||
# every 4.days do
|
||||
# runner "AnotherModel.prune_old_records"
|
||||
# end
|
||||
|
||||
# Learn more: http://github.com/javan/whenever
|
||||
|
||||
set :job_template, "/bin/sh -c ':job'"
|
||||
set :output, "log/cron.log"
|
||||
|
||||
# Perform an e621 status update every minute
|
||||
every 1.minute do
|
||||
rake "e621:status_update"
|
||||
end
|
||||
|
||||
# Update e621 exports at 12AM UTC
|
||||
# E621 generates them somewhere around 7AM UTC (usually finishing around 7:45AM), but we're being safe
|
||||
every :day, at: "10:50am" do
|
||||
rake "e621:exports"
|
||||
end
|
@ -3,7 +3,7 @@
|
||||
namespace :e621 do
|
||||
desc "Tasks related to e621"
|
||||
task status_update: :environment do
|
||||
E621StatusUpdater.run
|
||||
E621StatusUpdateJob.perform_now
|
||||
end
|
||||
|
||||
task remove_timeouts: :environment do
|
||||
|
Loading…
Reference in New Issue
Block a user