module Sleepier

Sleepier is a Process Management tool in the style of a supervisor. It most similar to the Erlang supervisor behaviour.

The basic usage of Sleepier is:

  1. Create an `Array` of `Sleepier::ChildSpec` objects

  2. Initialize a `Sleepier::Supervisor` object with the array of `Sleepier::ChildSpec` objects

  3. Create a new `Thread` and call `monitor` on the supervisor object within the thread

  4. Call `start` on the supervisor

Note that `start` will return as soon as the processes are started, and does not wait for them to finish.

Features:

Constants

VALID_RESTART_OPTIONS

The different styles which can be used to manage restarts

  • :permanent - Always restart the process, except when it has been restarted more than `max_restart_count` times in `max_restart_window` seconds

  • :temporary - Never restart the process

  • :transient - Only restart the process if it failed and hasn't been restarted more than `max_restart_count` times in `max_restart_window` seconds

VALID_SHUTDOWN_OPTIONS

How to shutdown the process

  • :brutal_kill - Terminate immediately, without giving it a chance to terminate gracefully. Equivalent to a kill -9 on Linux

  • :timeout - Attempt to terminate gracefully, but after `shutdown_timeout` seconds, brutally kill

  • :infinity - Terminate gracefully, even if it takes forever. USE WITH CAUTION! THIS CAN RESULT IN NEVER-ENDING PROCESSES

Public Class Methods

logger() click to toggle source

Logger used by sleepier functionality

# File lib/sleepier.rb, line 41
def self.logger
  @@logger
end
logger=(logger) click to toggle source

Configure the sleepier logger to another Ruby Logger-style logger

@param logger [Logger] The new logger to use

# File lib/sleepier.rb, line 48
def self.logger=(logger)
  @@logger = logger
end