mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 14:23:38 +00:00
Merge branch 'issue-9367' into 'rails'
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Issue #9367 See merge request sutty/sutty!184
This commit is contained in:
commit
41acc89e37
12 changed files with 48 additions and 29 deletions
2
Gemfile
2
Gemfile
|
@ -71,7 +71,7 @@ gem 'rollups', git: 'https://github.com/fauno/rollup.git', branch: 'update'
|
||||||
gem 'rubyzip'
|
gem 'rubyzip'
|
||||||
gem 'rugged'
|
gem 'rugged'
|
||||||
gem 'concurrent-ruby-ext'
|
gem 'concurrent-ruby-ext'
|
||||||
gem 'sucker_punch'
|
gem 'que'
|
||||||
gem 'symbol-fstring', require: 'fstring/all'
|
gem 'symbol-fstring', require: 'fstring/all'
|
||||||
gem 'terminal-table'
|
gem 'terminal-table'
|
||||||
gem 'validates_hostname'
|
gem 'validates_hostname'
|
||||||
|
|
|
@ -120,9 +120,6 @@ GEM
|
||||||
colorator (1.1.0)
|
colorator (1.1.0)
|
||||||
commonmarker (0.21.2-x86_64-linux-musl)
|
commonmarker (0.21.2-x86_64-linux-musl)
|
||||||
ruby-enum (~> 0.5)
|
ruby-enum (~> 0.5)
|
||||||
concurrent-ruby (1.1.9)
|
|
||||||
concurrent-ruby-ext (1.1.9-x86_64-linux-musl)
|
|
||||||
concurrent-ruby (= 1.1.9)
|
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
database_cleaner (2.0.1)
|
database_cleaner (2.0.1)
|
||||||
database_cleaner-active_record (~> 2.0.0)
|
database_cleaner-active_record (~> 2.0.0)
|
||||||
|
@ -413,6 +410,7 @@ GEM
|
||||||
pundit (2.1.1)
|
pundit (2.1.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
racc (1.6.0-x86_64-linux-musl)
|
racc (1.6.0-x86_64-linux-musl)
|
||||||
|
que (2.2.0)
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
rack-cors (1.1.1)
|
rack-cors (1.1.1)
|
||||||
rack (>= 2.0.0)
|
rack (>= 2.0.0)
|
||||||
|
@ -553,9 +551,6 @@ GEM
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.4.2-x86_64-linux-musl)
|
sqlite3 (1.4.2-x86_64-linux-musl)
|
||||||
stackprof (0.2.17-x86_64-linux-musl)
|
stackprof (0.2.17-x86_64-linux-musl)
|
||||||
stream (0.5.5)
|
|
||||||
sucker_punch (3.0.1)
|
|
||||||
concurrent-ruby (~> 1.0)
|
|
||||||
sutty-archives (2.5.4)
|
sutty-archives (2.5.4)
|
||||||
jekyll (>= 3.6, < 5.0)
|
jekyll (>= 3.6, < 5.0)
|
||||||
sutty-liquid (0.7.4)
|
sutty-liquid (0.7.4)
|
||||||
|
@ -665,6 +660,7 @@ DEPENDENCIES
|
||||||
pry
|
pry
|
||||||
puma
|
puma
|
||||||
pundit
|
pundit
|
||||||
|
que
|
||||||
rack-cors
|
rack-cors
|
||||||
rack-mini-profiler
|
rack-mini-profiler
|
||||||
rails (~> 6)
|
rails (~> 6)
|
||||||
|
@ -685,7 +681,6 @@ DEPENDENCIES
|
||||||
spring-watcher-listen (~> 2.0.0)
|
spring-watcher-listen (~> 2.0.0)
|
||||||
sqlite3
|
sqlite3
|
||||||
stackprof
|
stackprof
|
||||||
sucker_punch
|
|
||||||
sutty-liquid (>= 0.7.3)
|
sutty-liquid (>= 0.7.3)
|
||||||
symbol-fstring
|
symbol-fstring
|
||||||
terminal-table
|
terminal-table
|
||||||
|
|
2
Procfile
2
Procfile
|
@ -8,4 +8,4 @@ prometheus: bundle exec prometheus_exporter -b 0.0.0.0 --prefix "sutty_"
|
||||||
distributed_press_tokens_renew: bundle exec rake distributed_press:tokens:renew
|
distributed_press_tokens_renew: bundle exec rake distributed_press:tokens:renew
|
||||||
cleanup: bundle exec rake cleanup:everything
|
cleanup: bundle exec rake cleanup:everything
|
||||||
stats: bundle exec rake stats:process_all
|
stats: bundle exec rake stats:process_all
|
||||||
distributed_press_renew_tokens: bundle exec rake distributed_press:tokens:renew
|
que: daemonize -c /srv/ -p /srv/tmp/que.pid -u rails /usr/local/bin/syslogize bundle exec que
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Base para trabajos
|
# Base para trabajos
|
||||||
class ApplicationJob < ActiveJob::Base
|
class ApplicationJob < ActiveJob::Base
|
||||||
include SuckerPunch::Job
|
include Que::ActiveJob::JobExtensions
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ class BacktraceJob < ApplicationJob
|
||||||
|
|
||||||
EMPTY_SOURCEMAP = { 'mappings' => '' }.freeze
|
EMPTY_SOURCEMAP = { 'mappings' => '' }.freeze
|
||||||
|
|
||||||
queue_as :low_priority
|
|
||||||
|
|
||||||
attr_reader :params, :site_id
|
attr_reader :params, :site_id
|
||||||
|
|
||||||
def perform(site_id:, params:)
|
def perform(site_id:, params:)
|
||||||
|
|
|
@ -10,8 +10,6 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
# Variables que vamos a acceder luego
|
# Variables que vamos a acceder luego
|
||||||
attr_reader :exception, :options, :issue_data, :cached
|
attr_reader :exception, :options, :issue_data, :cached
|
||||||
|
|
||||||
queue_as :low_priority
|
|
||||||
|
|
||||||
# @param [Exception] la excepción lanzada
|
# @param [Exception] la excepción lanzada
|
||||||
# @param [Hash] opciones de ExceptionNotifier
|
# @param [Hash] opciones de ExceptionNotifier
|
||||||
def perform(exception, **options)
|
def perform(exception, **options)
|
||||||
|
|
22
app/lib/active_job/serializers/exception_serializer.rb
Normal file
22
app/lib/active_job/serializers/exception_serializer.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'json/add/exception'
|
||||||
|
|
||||||
|
module ActiveJob
|
||||||
|
module Serializers
|
||||||
|
class ExceptionSerializer < ObjectSerializer # :nodoc:
|
||||||
|
def serialize(ex)
|
||||||
|
super('value' => { 'class' => ex.class.name, 'exception' => ex.as_json })
|
||||||
|
end
|
||||||
|
|
||||||
|
def deserialize(hash)
|
||||||
|
hash.dig('value', 'class').constantize.json_create(hash.dig('value', 'exception'))
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def klass
|
||||||
|
Exception
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -39,6 +39,12 @@ module Sutty
|
||||||
config.active_storage.variant_processor = :vips
|
config.active_storage.variant_processor = :vips
|
||||||
config.active_storage.web_image_content_types << 'image/webp'
|
config.active_storage.web_image_content_types << 'image/webp'
|
||||||
|
|
||||||
|
# Que
|
||||||
|
config.action_mailer.deliver_later_queue_name = :default
|
||||||
|
config.active_storage.queues.analysis = :default
|
||||||
|
config.active_storage.queues.purge = :default
|
||||||
|
config.active_job.queue_adapter = :que
|
||||||
|
|
||||||
config.to_prepare do
|
config.to_prepare do
|
||||||
# Load application's model / class decorators
|
# Load application's model / class decorators
|
||||||
Dir.glob(File.join(File.dirname(__FILE__), '..', 'app', '**', '*_decorator.rb')).sort.each do |c|
|
Dir.glob(File.join(File.dirname(__FILE__), '..', 'app', '**', '*_decorator.rb')).sort.each do |c|
|
||||||
|
|
|
@ -64,11 +64,6 @@ Rails.application.configure do
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
config.cache_store = :redis_cache_store, { url: ENV['REDIS_SERVER'] }
|
config.cache_store = :redis_cache_store, { url: ENV['REDIS_SERVER'] }
|
||||||
|
|
||||||
# Use a real queuing backend for Active Job (and separate queues per
|
|
||||||
# environment)
|
|
||||||
config.active_job.queue_adapter = :sucker_punch
|
|
||||||
config.active_job.queue_name_prefix = "sutty_#{Rails.env}"
|
|
||||||
|
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
# Ignore bad email addresses and do not raise email delivery errors.
|
# Ignore bad email addresses and do not raise email delivery errors.
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Enviar una notificación cuando falla una tarea
|
|
||||||
SuckerPunch.exception_handler = lambda { |ex, _, args|
|
|
||||||
ExceptionNotifier.notify_exception(ex, data: args.last)
|
|
||||||
}
|
|
12
db/migrate/20230328231029_create_que_tables.rb
Normal file
12
db/migrate/20230328231029_create_que_tables.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Que
|
||||||
|
class CreateQueTables < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
Que.migrate! version: 7
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
Que.migrate! version: 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -19,7 +19,6 @@ check program stats
|
||||||
every "0 1 * * *"
|
every "0 1 * * *"
|
||||||
if status != 0 then alert
|
if status != 0 then alert
|
||||||
|
|
||||||
check program distributed_press_tokens_renew
|
check process que with pidfile /srv/tmp/que.pid
|
||||||
with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data"
|
start program = "/usr/bin/foreman run -f /srv/Procfile -d /srv que"
|
||||||
every "0 3 * * *"
|
stop program = "/bin/sh -c 'cat /srv/tmp/que.pid | xargs -r kill'"
|
||||||
if status != 0 then alert
|
|
||||||
|
|
Loading…
Reference in a new issue