Module: Resque::Kubernetes::Worker

Defined in:
lib/resque/kubernetes/worker.rb

Overview

Patches the resque worker to terminate when the queue is empty.

This patch enables setting an environment variable, ‘TERM_ON_EMPTY` that causes the worker to shutdown when the queue no longer has any resque jobs. This allows running workers as Kuberenetes Jobs that will terminate when there is no longer any work to do.

To use, make sure that the container images that hold your workers are built to include the ‘resque-kubernetes` gem and set `TERM_ON_EMPTY` in their environment to a truthy value (e.g. “1”).

Defined Under Namespace

Modules: InstanceMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#term_on_emptyObject

Returns the value of attribute term_on_empty.



24
25
26
# File 'lib/resque/kubernetes/worker.rb', line 24

def term_on_empty
  @term_on_empty
end

Class Method Details

.included(base) ⇒ Object



18
19
20
21
22
# File 'lib/resque/kubernetes/worker.rb', line 18

def self.included(base)
  base.class_eval do
    prepend InstanceMethods
  end
end