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:
-
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
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 used by sleepier functionality
# File lib/sleepier.rb, line 41 def self.logger @@logger end
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