mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-24 23:56:23 +00:00
cambiar sidekiq por sucker_punch
This commit is contained in:
parent
2b45f4c8d1
commit
2169291c29
14 changed files with 16 additions and 105 deletions
2
Gemfile
2
Gemfile
|
@ -57,7 +57,7 @@ gem 'redis-rails'
|
|||
gem 'reverse_markdown', git: 'https://0xacab.org/sutty/reverse_markdown.git'
|
||||
gem 'rubyzip'
|
||||
gem 'rugged'
|
||||
gem 'sidekiq'
|
||||
gem 'sucker_punch'
|
||||
gem 'terminal-table'
|
||||
gem 'validates_hostname'
|
||||
gem 'webpacker'
|
||||
|
|
12
Gemfile.lock
12
Gemfile.lock
|
@ -107,7 +107,6 @@ GEM
|
|||
commonmarker (0.20.1)
|
||||
ruby-enum (~> 0.5)
|
||||
concurrent-ruby (1.1.5)
|
||||
connection_pool (2.2.2)
|
||||
crass (1.0.4)
|
||||
database_cleaner (1.7.0)
|
||||
devise (4.7.1)
|
||||
|
@ -252,8 +251,6 @@ GEM
|
|||
pundit (2.1.0)
|
||||
activesupport (>= 3.0.0)
|
||||
rack (2.0.7)
|
||||
rack-protection (2.0.7)
|
||||
rack
|
||||
rack-proxy (0.6.5)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
|
@ -360,11 +357,6 @@ GEM
|
|||
selenium-webdriver (3.142.4)
|
||||
childprocess (>= 0.5, < 3.0)
|
||||
rubyzip (~> 1.2, >= 1.2.2)
|
||||
sidekiq (6.0.0)
|
||||
connection_pool (>= 2.2.2)
|
||||
rack (>= 2.0.0)
|
||||
rack-protection (>= 2.0.0)
|
||||
redis (>= 4.1.0)
|
||||
simpleidn (0.1.1)
|
||||
unf (~> 0.1.4)
|
||||
spring (2.1.0)
|
||||
|
@ -382,6 +374,8 @@ GEM
|
|||
sshkit (1.20.0)
|
||||
net-scp (>= 1.1.2)
|
||||
net-ssh (>= 2.8.0)
|
||||
sucker_punch (2.1.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
sysexits (1.2.0)
|
||||
temple (0.8.1)
|
||||
terminal-table (1.8.0)
|
||||
|
@ -471,10 +465,10 @@ DEPENDENCIES
|
|||
rugged
|
||||
sass-rails (~> 5.0)
|
||||
selenium-webdriver
|
||||
sidekiq
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
sqlite3
|
||||
sucker_punch
|
||||
terminal-table
|
||||
turbolinks (~> 5)
|
||||
uglifier (>= 1.3.0)
|
||||
|
|
1
Procfile
1
Procfile
|
@ -1,3 +1,2 @@
|
|||
migrate: if test -f data/production.sqlite3; then bundle exec rake db:migrate db:seed ; else bundle exec rake db:setup ; fi
|
||||
sutty: bundle exec puma -d config.ru
|
||||
sidekiq: bundle exec sidekiq -t 1
|
||||
|
|
|
@ -70,7 +70,7 @@ class SitesController < ApplicationController
|
|||
authorize site
|
||||
|
||||
# XXX: Convertir en una máquina de estados?
|
||||
DeployWorker.perform_async site.id if site.enqueue!
|
||||
DeployJob.perform_async site.id if site.enqueue!
|
||||
|
||||
redirect_to sites_path
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Base para trabajos
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
include SuckerPunch::Job
|
||||
end
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Realiza el deploy de un sitio
|
||||
class DeployWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
class DeployJob < ApplicationJob
|
||||
def perform(site)
|
||||
site = Site.find(site)
|
||||
site.update_attribute :status, 'building'
|
32
bin/sidekiq
32
bin/sidekiq
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'sidekiq' 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', __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300) =~ /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('sidekiq', 'sidekiq')
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'sidekiqctl' 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', __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 300) =~ /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('sidekiq', 'sidekiqctl')
|
|
@ -67,7 +67,7 @@ Rails.application.configure do
|
|||
|
||||
# Use a real queuing backend for Active Job (and separate queues per
|
||||
# environment)
|
||||
config.active_job.queue_adapter = :sidekiq
|
||||
config.active_job.queue_adapter = :sucker_punch
|
||||
config.active_job.queue_name_prefix = "sutty_#{Rails.env}"
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = {
|
||||
url: ENV.fetch('REDIS_SERVER', 'redis://localhost:6379/1')
|
||||
}
|
||||
end
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = {
|
||||
url: ENV.fetch('REDIS_CLIENT', 'redis://localhost:6379/1')
|
||||
}
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
check process sutty with pidfile /srv/http/tmp/puma.pid
|
||||
start program = "/bin/sh -c 'cd /srv/http && foreman start migrate && foreman start sutty && foreman start sidekiq'" as uid app
|
||||
start program = "/bin/sh -c 'cd /srv/http && foreman start migrate && foreman start sutty'" as uid app
|
||||
stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'"
|
||||
|
||||
check program sync_assets
|
||||
|
|
|
@ -88,14 +88,11 @@ class SitesControllerTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
test 'se pueden encolar' do
|
||||
Sidekiq::Testing.fake!
|
||||
|
||||
post site_enqueue_url(@site), headers: @authorization
|
||||
|
||||
assert DeployWorker.jobs.count.positive?
|
||||
assert @site.reload.enqueued?
|
||||
|
||||
Sidekiq::Testing.inline!
|
||||
assert File.directory?(@site.deploys.first.destination)
|
||||
assert File.exist?(File.join(@site.deploys.first.destination,
|
||||
'index.html'))
|
||||
end
|
||||
|
||||
test 'se pueden actualizar' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeployWorkerTest < ActiveSupport::TestCase
|
||||
class DeployJobTest < ActiveSupport::TestCase
|
||||
test 'se puede compilar' do
|
||||
rol = create :rol
|
||||
site = rol.site
|
||||
|
@ -8,7 +8,7 @@ class DeployWorkerTest < ActiveSupport::TestCase
|
|||
|
||||
site.save
|
||||
|
||||
DeployWorker.perform_async(site.id)
|
||||
DeployJob.perform_async(site.id)
|
||||
|
||||
assert_not ActionMailer::Base.deliveries.empty?
|
||||
|
|
@ -3,9 +3,7 @@
|
|||
require File.expand_path('../config/environment', __dir__)
|
||||
require 'rails/test_help'
|
||||
require 'open3'
|
||||
|
||||
require 'sidekiq/testing'
|
||||
Sidekiq::Testing.inline!
|
||||
require 'sucker_punch/testing/inline'
|
||||
|
||||
# rubocop:disable Style/ClassAndModuleChildren
|
||||
class ActiveSupport::TestCase
|
||||
|
|
Loading…
Reference in a new issue