Skip to content

Commit

Permalink
confirm resque task environment is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBlackLight committed Oct 31, 2024
1 parent 6ae7e26 commit 712ee97
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.6.2
4.7.7
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ class Application < Rails::Application
config.active_job.queue_adapter = :async

config.active_storage.service = :local

ENVIRONMENTS = Dir.glob(Rails.root.join("config/environments/*.rb")).map { |file|
File.basename(file, ".rb")
}.freeze
end
end
16 changes: 16 additions & 0 deletions config/resque.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
development:
workers:
"*": 2
test:
workers:
"*": 4
prod:
workers:
"*": 6

academiccommons_test:
workers:
"*": 4
academiccommons_prod:
workers:
"*": 6
4 changes: 2 additions & 2 deletions lib/tasks/resque.rake
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ namespace :resque do
err = Rails.root.join('log', 'resque.log').to_s
out = Rails.root.join('log', 'resque.log').to_s
rails_env = ENV['RAILS_ENV']
return unless AcademicCommons::Application::ENVIRONMENTS.include(rails_env)

worker_config.each do |queues, count|
queues = queues.to_s
count.times do |index|
number = index + 1
pidfile = Rails.root.join('tmp/pids/', "resque_work_#{number}.pid").to_s
_stdout_str, _stderr_str, status = Open3.capture3("RAILS_ENV=#{rails_env} QUEUE=\"#{queues}\" PIDFILE=#{pidfile} BACKGROUND=yes VERBOSE=1 INTERVAL=#{interval} rake resque:work >> #{out} 2>> #{err}")
puts "Worker #{number} started, status: #{status}"
Open3.capture3("RAILS_ENV=#{rails_env} QUEUE=\"#{queues}\" PIDFILE=#{pidfile} BACKGROUND=yes VERBOSE=1 INTERVAL=#{interval} rake resque:work >> #{out} 2>> #{err}")
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/api_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rails_helper'
require 'rake'

RSpec.describe 'ac:generate_api_token', type: :task do
before do
Token.delete_all
end

after do
Rake.application.clear
end

xit 'generates a new token record' do
email = 'test@test.org'
description = 'test description'
Rake::Task['ac:generate_api_token'].invoke(email, description)
expect(Token.count).to eq(1)
end
end

0 comments on commit 712ee97

Please sign in to comment.