Module: Sleepier
- Defined in:
- lib/sleepier.rb
Overview
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:
-
Create an ‘Array` of `Sleepier::ChildSpec` objects
-
Initialize a ‘Sleepier::Supervisor` object with the array of `Sleepier::ChildSpec` objects
-
Create a new ‘Thread` and call `monitor` on the supervisor object within the thread
-
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:
-
Starting and stopping processes
-
Rapid termination handling
-
Several process shutdown strategies
-
Different process lifecycles
-
Pluggable logging
Defined Under Namespace
Classes: ChildSpec, Supervisor
Constant Summary collapse
- 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
-
[:permanent, :temporary, :transient]
- 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
-
[:brutal_kill, :timeout, :infinity]
- @@logger =
Logger.new(STDOUT)
Class Method Summary collapse
-
.logger ⇒ Object
Logger used by sleepier functionality.
-
.logger=(logger) ⇒ Object
Configure the sleepier logger to another Ruby Logger-style logger.
Class Method Details
.logger ⇒ Object
Logger used by sleepier functionality
41 42 43 |
# File 'lib/sleepier.rb', line 41 def self.logger @@logger end |
.logger=(logger) ⇒ Object
Configure the sleepier logger to another Ruby Logger-style logger
48 49 50 |
# File 'lib/sleepier.rb', line 48 def self.logger=(logger) @@logger = logger end |