### Setup Development Environment Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Run this command to set up the development environment, including loading seed jobs. ```bash bin/setup ``` -------------------------------- ### Install Bundled Gems Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Execute this command after adding the gem to your Gemfile to install it. ```bash $ bundle install ``` -------------------------------- ### Configure Apps and Servers with Custom Redis Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Set up multiple applications and their respective servers, including custom Redis connections for each. This example demonstrates configuring Resque and Solid Queue adapters with distinct Redis namespaces. ```ruby require "resque" require "resque_pause_helper" require "solid_queue" Resque.redis = Redis::Namespace.new "#{Rails.env}", redis: Redis.new(host: "localhost", port: 6379) SERVERS_BY_APP = { BC4: %w[ resque_ashburn resque_chicago ], HEY: %w[ resque solid_queue ] } def redis_connection_for(app, server) redis_namespace = Redis::Namespace.new "#{app}:#{server}", redis: Resque.redis.instance_variable_get("@redis") Resque::DataStore.new redis_namespace end SERVERS_BY_APP.each do |app, servers| queue_adapters_by_name = servers.collect do |server| queue_adapter = if server.start_with?("resque") ActiveJob::QueueAdapters::ResqueAdapter.new(redis_connection_for(app, server)) else ActiveJob::QueueAdapters::SolidQueueAdapter.new end # Default: # # @return Array> # * This is equivalent, and behaves identically to, the format the default format above. # [ server, [ queue_adapter ]] # without optional backtrace cleaner # # @return Array> # * This format adds an optional ActiveSupport::BacktraceCleaner to override the system wide # backtrace cleaner for *this* Application Server/Service. # [ server, [ queue_adapter, BacktraceCleaner.new ]] # with optional backtrace cleaner end.to_h MissionControl::Jobs.applications.add(app, queue_adapters_by_name) end ``` -------------------------------- ### Migrate from Resque to Solid Queue Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Configure both Resque and Solid Queue adapters within Mission Control Jobs during a migration. This example shows how to initialize both adapters and add them to a specific application. ```ruby queue_adapters_by_name = { resque: ActiveJob::QueueAdapters.lookup(:resque).new, # This will use Resque.redis as the redis client solid_queue: ActiveJob::QueueAdapters.lookup(:solid_queue).new } MissionControl::Jobs.applications.add("hey", queue_adapters_by_name) ``` -------------------------------- ### Run System Tests Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Execute system tests after installing ChromeDriver. This command runs all system tests. ```bash bin/rails test test/system ``` -------------------------------- ### Add Mission Control Jobs to Gemfile Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Include the gem in your application's Gemfile to start using Mission Control Jobs. ```ruby gem "mission_control-jobs" ``` -------------------------------- ### Run Authentication Configuration Generator Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Use this generator to set up HTTP basic authentication credentials for Mission Control Jobs. ```bash bin/rails mission_control:jobs:authentication:configure ``` -------------------------------- ### Display Job Server Help Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Type 'jobs_help' in the Rails console to view instructions on connecting to job servers. ```ruby jobs_help ``` -------------------------------- ### Connect to a Specific Job Server Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Use the 'connect_to' command with the application and server ID to switch to a specific job server. ```ruby connect_to "hey:solid_queue" ``` -------------------------------- ### Precompile Assets for Production Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Ensure assets are precompiled during the deployment pipeline for production environments. ```bash RAILS_ENV=production rails assets:precompile ``` -------------------------------- ### Configure Multiple Adapters Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Specify the job adapters to be supported by Mission Control. This setting enables the use of multiple queue adapters. ```ruby config.mission_control.jobs.adapters = [ :resque, :solid_queue ] ``` -------------------------------- ### Precompile Assets in Dockerfile Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Include this command in your Dockerfile to precompile assets for production in API-only apps or those skipping the default assets pipeline. ```bash # Precompiling assets for production without requiring secret RAILS_MASTER_KEY RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile ``` -------------------------------- ### Connect to Rails Console Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Connect to the Rails console to access Mission Control Jobs helpers. Type 'jobs_help' to see available commands. ```bash bin/rails c ``` -------------------------------- ### Query All Jobs Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retrieve all jobs managed by the currently connected adapter. ```ruby ActiveJob.jobs ``` -------------------------------- ### Configure HTTP Basic Authentication Credentials Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Set HTTP basic authentication credentials in Rails's credentials file for Mission Control Jobs. ```yaml mission_control: http_basic_auth_user: dev http_basic_auth_password: secret ``` -------------------------------- ### Query All Failed Jobs Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retrieve only the failed jobs from the connected adapter. ```ruby ActiveJob.jobs.failed ``` -------------------------------- ### Query Pending Jobs with Limit and Offset Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retrieve a specific subset of pending jobs by applying limit and offset. Useful for pagination or processing large job sets. ```ruby ActiveJob.jobs.pending.where(job_class_name: "SomeJob").limit(10).offset(5) ``` -------------------------------- ### Configure Authentication for Production Environment Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Specify the RAILS_ENV when running the authentication configuration generator for different environments. ```bash RAILS_ENV=production bin/rails mission_control:jobs:authentication:configure ``` -------------------------------- ### Query In-Progress Jobs by Class Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retrieve jobs currently in progress, filtered by their class name. This functionality depends on adapter support. ```ruby ActiveJob.jobs.in_progress.where(job_class_name: "SomeJob") ``` -------------------------------- ### Manually Configure HTTP Basic Auth Credentials Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Alternatively, configure HTTP basic authentication credentials directly in your Rails application configuration. ```ruby Rails.application.configure do MissionControl::Jobs.http_basic_auth_user = "dev" MissionControl::Jobs.http_basic_auth_password = "secret" end ``` -------------------------------- ### Mount Mission Control Jobs Engine Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Mount the Mission Control Jobs engine in your application's routes to make its UI accessible. ```ruby Rails.application.routes.draw do # ... mount MissionControl::Jobs::Engine, at: "/jobs" end ``` -------------------------------- ### Configure Base Controller Class in Environment Config Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Set the base controller class for Mission Control Jobs within your environment configuration or application.rb. ```ruby config.mission_control.jobs.base_controller_class = "AdminController" ``` -------------------------------- ### Retry All Failed Jobs Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Initiate a retry for all failed jobs. This operation is only applicable to failed jobs. ```ruby ActiveJob.jobs.failed.retry_all ``` -------------------------------- ### Set Custom Base Controller Class Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Specify a custom controller class for Mission Control's controllers to enable custom authentication mechanisms. ```ruby Rails.application.configure do MissionControl::Jobs.base_controller_class = "AdminController" end ``` -------------------------------- ### Query Pending Jobs by Queue Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Filter pending jobs by specifying their queue name. Requires the adapter to support queue name filtering. ```ruby ActiveJob.jobs.pending.where(queue_name: "some_queue") ``` -------------------------------- ### Query Scheduled Jobs by Class Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retrieve scheduled jobs filtered by their class name. This functionality depends on adapter support. ```ruby ActiveJob.jobs.scheduled.where(job_class_name: "SomeJob") ``` -------------------------------- ### Query Finished Jobs by Class Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retrieve jobs that have completed successfully, filtered by their class name. This functionality depends on adapter support. ```ruby ActiveJob.jobs.finished.where(job_class_name: "SomeJob") ``` -------------------------------- ### Add Propshaft for Asset Pipeline Source: https://github.com/rails/mission_control-jobs/blob/main/README.md For API-only apps or those using custom asset pipelines, add the 'propshaft' gem to manage assets. ```ruby gem "propshaft" ``` -------------------------------- ### Retry Failed Jobs by Class Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Retry only the failed jobs belonging to a specific class. This operation is only applicable to failed jobs. ```ruby ActiveJob.jobs.failed.where(job_class_name: "SomeJob").retry_all ``` -------------------------------- ### Discard All Failed Jobs Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Permanently remove all failed jobs. Use with caution. ```ruby ActiveJob.jobs.failed.discard_all ``` -------------------------------- ### Disable Default HTTP Basic Authentication Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Set this option to false if you are providing your own custom authentication mechanism. ```ruby config.mission_control.jobs.http_basic_auth_enabled = false ``` -------------------------------- ### Query Failed Jobs by Class Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Filter failed jobs by their class name. Useful for isolating issues with specific job types. ```ruby ActiveJob.jobs.failed.where(job_class_name: "SomeJob") ``` -------------------------------- ### Configure Delay Between Bulk Operations Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Modify the delay in seconds between batches processed during bulk operations. This setting affects operations like retry_all and discard_all. ```ruby MissionControl::Jobs.delay_between_bulk_operation_batches = 5.seconds ``` -------------------------------- ### Query In-Progress Jobs by Worker ID Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Filter jobs currently in progress by the ID of the worker processing them. This functionality depends on adapter support. ```ruby ActiveJob.jobs.in_progress.where(worker_id: 42) ``` -------------------------------- ### Discard Pending Jobs by Queue Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Permanently remove all pending jobs from a specific queue. Use with caution. ```ruby ActiveJob.jobs.pending.where(queue_name: "some-queue").discard_all ``` -------------------------------- ### Discard Pending Jobs by Class Name Source: https://github.com/rails/mission_control-jobs/blob/main/README.md Permanently remove all pending jobs of a specific class. Use with caution. ```ruby ActiveJob.jobs.pending.where(job_class_name: "SomeJob").discard_all ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.