Skip to content

About shutdown judgment of Worker Process #282

@tmimura39

Description

@tmimura39

Hi, I am currently trying to get SolidQueue support for the job-iteration gem. Shopify/job-iteration#496

A brief description of job-iteration is as follows

Meet Iteration, an extension for ActiveJob that makes your jobs interruptible and resumable, saving all progress that the job has made (aka checkpoint for jobs).

iteration-how-it-works

Here is what needs to be addressed for each Adapter.

The job iterates over two records of the relation and then receives SIGTERM (graceful termination signal) caused by a deploy.
The signal handler sets a flag that makes job_should_exit? return true.

I want to determine if the SolidQueue Worker Process is about to receive a TERM and shutdown.

Is this judgment correct?

# frozen_string_literal: true

begin
  require "solid_queue"
rescue LoadError
  # SolidQueue is not available, no need to load the adapter
  return
end

module JobIteration
  module InterruptionAdapters
    module SolidQueueAdapter
      class << self
        attr_accessor :stopping

        def call
          stopping
        end
      end
    end

    ActiveSupport::Notifications.subscribe("graceful_termination.solid_queue") do
      JobIteration::Integrations::SolidQueueAdapter.stopping = true
    end

    register(:solid_queue, SolidQueueAdapter)
  end
end

GoodJob has implemented a new feature for this.
bensheldon/good_job#1253

I would appreciate your advice as I am unable to determine if the same action is required for SolidQueue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions