Module God
In: lib/god.rb
lib/god/trigger.rb
lib/god/behaviors/notify_when_flapping.rb
lib/god/behaviors/clean_unix_socket.rb
lib/god/behaviors/clean_pid_file.rb
lib/god/simple_logger.rb
lib/god/process.rb
lib/god/behavior.rb
lib/god/conditions/complex.rb
lib/god/conditions/memory_usage.rb
lib/god/conditions/lambda.rb
lib/god/conditions/degrading_lambda.rb
lib/god/conditions/disk_usage.rb
lib/god/conditions/cpu_usage.rb
lib/god/conditions/socket_responding.rb
lib/god/conditions/flapping.rb
lib/god/conditions/tries.rb
lib/god/conditions/process_exits.rb
lib/god/conditions/http_response_code.rb
lib/god/conditions/process_running.rb
lib/god/conditions/file_mtime.rb
lib/god/conditions/always.rb
lib/god/timeline.rb
lib/god/driver.rb
lib/god/cli/version.rb
lib/god/cli/command.rb
lib/god/cli/run.rb
lib/god/event_handlers/kqueue_handler.rb
lib/god/event_handlers/dummy_handler.rb
lib/god/event_handlers/netlink_handler.rb
lib/god/metric.rb
lib/god/system/process.rb
lib/god/system/portable_poller.rb
lib/god/system/slash_proc_poller.rb
lib/god/configurable.rb
lib/god/sys_logger.rb
lib/god/logger.rb
lib/god/event_handler.rb
lib/god/contact.rb
lib/god/registry.rb
lib/god/task.rb
lib/god/contacts/email.rb
lib/god/contacts/jabber.rb
lib/god/contacts/webhook.rb
lib/god/contacts/prowl.rb
lib/god/contacts/twitter.rb
lib/god/contacts/campfire.rb
lib/god/contacts/scout.rb
lib/god/socket.rb
lib/god/errors.rb
lib/god/watch.rb
lib/god/condition.rb

Methods

at_exit   contact   control   internal_init   join   load   pattern_match   registry   running_load   running_log   setup   signal   start   status   stop_all   task   terminate   uncontact   unwatch   version   watch  

Classes and Modules

Module God::Behaviors
Module God::CLI
Module God::Conditions
Module God::Configurable
Module God::Contacts
Module God::System
Class God::AbstractMethodNotOverriddenError
Class God::Behavior
Class God::Condition
Class God::Contact
Class God::Driver
Class God::DriverEvent
Class God::DriverEventQueue
Class God::DriverOperation
Class God::DummyHandler
Class God::EventCondition
Class God::EventHandler
Class God::EventRegistrationFailedError
Class God::InvalidCommandError
Class God::KQueueHandler
Class God::Logger
Class God::Metric
Class God::NetlinkHandler
Class God::NoSuchBehaviorError
Class God::NoSuchConditionError
Class God::NoSuchContactError
Class God::NoSuchWatchError
Class God::PollCondition
Class God::Process
Class God::Registry
Class God::SimpleLogger
Class God::Socket
Class God::SysLogger
Class God::Task
Class God::TimedEvent
Class God::Timeline
Class God::Trigger
Class God::TriggerCondition
Class God::Watch

Constants

VERSION = '0.12.1'   The String version number for this package.
LOG_BUFFER_SIZE_DEFAULT = 100   The Integer number of lines of backlog to keep for the logger.
PID_FILE_DIRECTORY_DEFAULTS = ['/var/run/god', '~/.god/pids']   An Array of directory paths to be used as the default PID file directory. This list will be searched in order and the first one that has write permissions will be used.
DRB_PORT_DEFAULT = 17165   The default Integer port number for the DRb communcations channel.
DRB_ALLOW_DEFAULT = ['127.0.0.1']   The default Array of String IPs that will allow DRb communication access.
LOG_LEVEL_DEFAULT = :info   The default Symbol log level.
TERMINATE_TIMEOUT_DEFAULT = 10   The default Integer number of seconds to wait for god to terminate when issued the quit command.
STOP_TIMEOUT_DEFAULT = 10   The default Integer number of seconds to wait for a process to terminate.
STOP_SIGNAL_DEFAULT = 'TERM'   The default String signal to send for the stop command.

Attributes

contact_groups  [RW]  internal
contacts  [RW]  internal
groups  [RW]  internal
inited  [RW]  internal
main  [RW]  internal
pending_watch_states  [RW]  internal
pending_watches  [RW]  internal
running  [RW]  internal
server  [RW]  internal
watches  [RW]  internal

Public Class methods

To be called on program exit to start god.

Returns nothing.

Instantiate a new Contact of the given kind and send it to the block. Then prepare, validate, and record the Contact. Aborts on invalid kind, duplicate contact name, invalid contact, or conflicting group name.

kind - The Symbol contact class specifier.

Returns nothing.

Control the lifecycle of the given task(s).

name - The String name of a task/group. command - The String command to run. Valid commands are:

          "start", "monitor", "restart", "stop", "unmonitor", "remove".

Returns an Array of String task names affected by the command.

Initialize internal data.

Returns nothing.

Prevent god from exiting.

Returns nothing.

Load the given file(s) according to the given glob.

glob - The glob-enabled String path to load.

Returns nothing.

Match a shortened pattern against a list of String candidates. The pattern is expanded into a regular expression by inserting .* between each character.

pattern - The String containing the abbreviation. list - The Array of Strings to match against.

Examples

  list = %w{ foo bar bars }
  pattern = 'br'
  God.pattern_match(list, pattern)
  # => ['bar', 'bars']

Returns the Array of matching name Strings.

Load a config file into a running god instance. Rescues any exceptions that the config may raise and reports these back to the caller.

code - The String config file contents. filename - The filename of the config file. action - The optional String command specifying how to deal with

           existing watches. Valid options are: 'stop', 'remove' or
           'leave' (default).

Returns a three-tuple Array [loaded_names, errors, unloaded_names] where:

        loaded_names   - The Array of String task names that were loaded.
        errors         - The String of error messages produced during the
                         load phase. Will be a blank String if no errors
                         were encountered.
        unloaded_names - The Array of String task names that were unloaded
                         from the system (if 'remove' or 'stop' was
                         specified as the action).

Log lines for the given task since the specified time.

watch_name - The String name of the task (may be abbreviated). since - The Time since which to report log lines.

Raises God::NoSuchWatchError if no tasks matched. Returns the String of newline separated log lines.

Setup pid file directory and log system.

Returns nothing.

Send a signal to each task.

name - The String name of the task or group. signal - The String or integer signal to send. e.g. ‘HUP’, 9.

Returns an Array of String names of the tasks affected.

Initialize and startup the machinery that makes god work.

Returns nothing.

Gather the status of each task.

Examples

  God.status
  # => { 'mongrel' => :up, 'nginx' => :up }

Returns a Hash where the key is the String task name and the value is the

  Symbol status.

Unmonitor and stop all tasks.

Returns true on success, false if all tasks could not be stopped within 10 seconds

Instantiate a new, empty Task object and yield it to the mandatory block. The attributes of the task will be set by the configuration file. Aborts on duplicate task name, invalid task, or conflicting group name.

Returns nothing.

Force the termination of god.

  • Clean up pid file if one exists
  • Stop DRb service
  • Hard exit using exit!

Never returns because the process will no longer exist!

Remove the given contact from god.

contact - The Contact to remove.

Returns nothing.

Unmonitor and remove the given watch from god.

watch - The Watch to remove.

Returns nothing.

Returns the version String.

Instantiate a new, empty Watch object and pass it to the mandatory block. The attributes of the watch will be set by the configuration file. Aborts on duplicate watch name, invalid watch, or conflicting group name.

Returns nothing.

[Validate]