Merge branch 'issue-9367' into 'rails'
ci/woodpecker/push/woodpecker Pipeline was successful Details

Issue #9367

See merge request sutty/sutty!184
This commit is contained in:
fauno 2023-05-15 20:04:27 +00:00
commit 41acc89e37
12 changed files with 48 additions and 29 deletions

View File

@ -71,7 +71,7 @@ gem 'rollups', git: 'https://github.com/fauno/rollup.git', branch: 'update'
gem 'rubyzip'
gem 'rugged'
gem 'concurrent-ruby-ext'
gem 'sucker_punch'
gem 'que'
gem 'symbol-fstring', require: 'fstring/all'
gem 'terminal-table'
gem 'validates_hostname'

View File

@ -120,9 +120,6 @@ GEM
colorator (1.1.0)
commonmarker (0.21.2-x86_64-linux-musl)
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)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
@ -413,6 +410,7 @@ GEM
pundit (2.1.1)
activesupport (>= 3.0.0)
racc (1.6.0-x86_64-linux-musl)
que (2.2.0)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
@ -553,9 +551,6 @@ GEM
sprockets (>= 3.0.0)
sqlite3 (1.4.2-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)
jekyll (>= 3.6, < 5.0)
sutty-liquid (0.7.4)
@ -665,6 +660,7 @@ DEPENDENCIES
pry
puma
pundit
que
rack-cors
rack-mini-profiler
rails (~> 6)
@ -685,7 +681,6 @@ DEPENDENCIES
spring-watcher-listen (~> 2.0.0)
sqlite3
stackprof
sucker_punch
sutty-liquid (>= 0.7.3)
symbol-fstring
terminal-table

View File

@ -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
cleanup: bundle exec rake cleanup:everything
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

View File

@ -2,7 +2,7 @@
# Base para trabajos
class ApplicationJob < ActiveJob::Base
include SuckerPunch::Job
include Que::ActiveJob::JobExtensions
private

View File

@ -6,8 +6,6 @@ class BacktraceJob < ApplicationJob
EMPTY_SOURCEMAP = { 'mappings' => '' }.freeze
queue_as :low_priority
attr_reader :params, :site_id
def perform(site_id:, params:)

View File

@ -10,8 +10,6 @@ class GitlabNotifierJob < ApplicationJob
# Variables que vamos a acceder luego
attr_reader :exception, :options, :issue_data, :cached
queue_as :low_priority
# @param [Exception] la excepción lanzada
# @param [Hash] opciones de ExceptionNotifier
def perform(exception, **options)

View 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

View File

@ -39,6 +39,12 @@ module Sutty
config.active_storage.variant_processor = :vips
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
# Load application's model / class decorators
Dir.glob(File.join(File.dirname(__FILE__), '..', 'app', '**', '*_decorator.rb')).sort.each do |c|

View File

@ -64,11 +64,6 @@ Rails.application.configure do
# Use a different cache store in production.
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
# Ignore bad email addresses and do not raise email delivery errors.

View File

@ -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)
}

View 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

View File

@ -19,7 +19,6 @@ check program stats
every "0 1 * * *"
if status != 0 then alert
check program distributed_press_tokens_renew
with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data"
every "0 3 * * *"
if status != 0 then alert
check process que with pidfile /srv/tmp/que.pid
start program = "/usr/bin/foreman run -f /srv/Procfile -d /srv que"
stop program = "/bin/sh -c 'cat /srv/tmp/que.pid | xargs -r kill'"