Class God::Watch
In: lib/god/watch.rb
Parent: Task

The Watch class is a specialized Task that handles standard process workflows. It has four states: init, up, start, and restart.

Methods

Constants

VALID_STATES = [:init, :up, :start, :restart]   The Array of Symbol valid task states.
INITIAL_STATE = :init   The Sybmol initial state.
DEFAULT_KEEPALIVE_INTERVAL = 5.seconds   Default Integer interval at which keepalive will runn poll checks.
DEFAULT_KEEPALIVE_MEMORY_TIMES = [3, 5]   Default Integer or Array of Integers specification of how many times the memory condition must fail before triggering.
DEFAULT_KEEPALIVE_CPU_TIMES = [3, 5]   Default Integer or Array of Integers specification of how many times the CPU condition must fail before triggering.

Attributes

grace  [RW]  Public: The grace period for this process (seconds).
restart_grace  [RW]  Public: The restart grace period (seconds).
start_grace  [RW]  Public: The start grace period (seconds).
stop_grace  [RW]  Public: The stop grace period (seconds).

Public Class methods

Initialize a new Watch instance.

Public Instance methods

Perform an action.

a - The Symbol action to perform. One of :start, :restart, :stop. c - The Condition.

Returns this Watch.

Public: Add a behavior to this Watch. See lib/god/behavior.rb.

kind - The Symbol name of the Behavior to add.

Yields the newly instantiated Behavior.

Returns nothing.

Perform the specifics of the action.

condition - The Condition. action - The Sybmol action.

Returns nothing.

Public: A set of conditions for easily getting started with simple watch scenarios. Keepalive is intended for use by beginners or on processes that do not need very sophisticated monitoring.

If events are enabled, it will use the :process_exit event to determine if a process fails. Otherwise it will use the :process_running poll.

options - The option Hash. Possible values are:

          :interval -     The Integer number of seconds on which to poll
                          for process status. Affects CPU, memory, and
                          :process_running conditions (if used).
                          Default: 5.seconds.
          :memory_max   - The Integer memory max. A bare integer means
                          kilobytes. You may use Numeric.kilobytes,
                          Numeric#megabytes, and Numeric#gigabytes to
                          makes things more clear.
          :memory_times - If :memory_max is set, :memory_times can be
                          set to either an Integer or a 2 element
                          Integer Array to specify the number of times
                          the memory condition must fail. Examples:
                          3 (three times), [3, 5] (three out of any five
                          checks). Default: [3, 5].
          :cpu_max      - The Integer CPU percentage max. Range is
                          0 to 100. You may use the Numberic#percent
                          sugar to clarify e.g. 50.percent.
          :cpu_times    - If :cpu_max is set, :cpu_times can be
                          set to either an Integer or a 2 element
                          Integer Array to specify the number of times
                          the memory condition must fail. Examples:
                          3 (three times), [3, 5] (three out of any five
                          checks). Default: [3, 5].

Enable monitoring. Start at the first available of the init or up states.

Returns nothing.

Register the Process in the global process registry.

Returns nothing.

Public: Restart the process if any of the given conditions are triggered.

Yields the Metric upon which conditions can be added.

Returns nothing.

Public: Start the process if any of the given conditions are triggered.

Yields the Metric upon which conditions can be added.

Returns nothing.

Public: Stop the process if any of the given conditions are triggered.

Yields the Metric upon which conditions can be added.

Returns nothing.

Unregister the Process in the global process registry.

Returns nothing.

Is this Watch valid?

Returns true if the Watch is valid, false if not.

[Validate]