Module: Loops

Includes:
Errors
Defined in:
lib/loops/version.rb,
lib/loops.rb,
lib/loops/cli.rb,
lib/loops/queue.rb,
lib/loops/worker.rb,
lib/loops/autoload.rb,
lib/loops/daemonize.rb,
lib/loops/cli/options.rb,
lib/loops/worker_pool.rb,
lib/loops/cli/commands.rb,
lib/loops/process_manager.rb

Overview

Contains information about currently used Loops version.

Examples:

puts "Loops #{Loops::Version::STRING}"

Defined Under Namespace

Modules: Commands, Daemonize, Errors, Version Classes: Base, CLI, Command, Engine, Logger, ProcessManager, Queue, Worker, WorkerPool

Constant Summary collapse

LIB_ROOT =

Returns a full path to the loops “lib” directory.

Returns:

  • (String)

    a full path to the loops “lib” directory.

File.expand_path(File.dirname(__FILE__))
BINARY =

Returns a full path to the loops binary file.

Returns:

  • (String)

    a full path to the loops binary file.

File.expand_path(File.join(LIB_ROOT, '../bin/loops'))

Constants included from Errors

Errors::Error, Errors::InvalidCommandError, Errors::InvalidFrameworkError

Class Method Summary collapse

Class Method Details

.__p(*path) ⇒ Object



3
# File 'lib/loops/autoload.rb', line 3

def self.__p(*path) File.join(Loops::LIB_ROOT, 'loops', *path) end

.config_filePathname

Get loops config file full path.

Returns:

  • (Pathname)

    the loops config file path.



47
48
49
# File 'lib/loops.rb', line 47

def self.config_file
  @@config_file ||= root.join('config/loops.yml')
end

.config_file=(config_file) ⇒ Pathname

Set loops config file path.

This is internal method used to set the loops config file path.

Parameters:

  • path (String)

    the absolute or relative to the loops root path of the loops config file.

Returns:

  • (Pathname)

    the loops config file path.



63
64
65
# File 'lib/loops.rb', line 63

def self.config_file=(config_file)
  @@config_file = root.join(config_file) if config_file
end

.default_loggerLogger

Get the current framework’s default logger.

Returns:

  • (Logger)

    the default logger for currently used framework.



149
150
151
# File 'lib/loops.rb', line 149

def self.default_logger
  @@default_logger
end

.default_logger=(logger) ⇒ Logger

Set the current framework’s default logger.

Parameters:

  • logger (Logger)

    the default logger for currently used framework.

Returns:

  • (Logger)

    the default logger for currently used framework.



162
163
164
# File 'lib/loops.rb', line 162

def self.default_logger=(logger)
  @@default_logger = logger
end

.loggerLoops::Logger

Get the current loops logger.

There are two contexts where different devices (usually) will be configured for this logger instance:

  1. In context of loops monitor logger device will be retrieved from the global section of the loops config file, or STDOUT when it was not configured.

  2. In context of loop proccess logger device will be configured based on logger value of the particular loop section in the config file.

Examples:

Put all Rails logging into the loop log file (add this to the environment.rb)

Rails.logger = Loops.logger

Returns:



134
135
136
# File 'lib/loops.rb', line 134

def self.logger
  @@logger ||= ::Loops::Logger.new($stdout)
end

.logger=(logger) ⇒ Object

Set the current loops logger.



140
141
142
# File 'lib/loops.rb', line 140

def self.logger=(logger)
  @@logger = logger
end

.loops_rootPathname

Get directory containing loops classes.

Returns:

  • (Pathname)

    the loops directory path.



72
73
74
# File 'lib/loops.rb', line 72

def self.loops_root
  @@loops_root ||= root.join('app/loops')
end

.loops_root=(loops_root) ⇒ Pathname

Set loops classes directory path.

This is internal method used to set directory where loops classes will be searched.

Parameters:

  • path (String)

    the absolute or relative to the loops classes directory.

Returns:

  • (Pathname)

    the loops classes directory path.



88
89
90
# File 'lib/loops.rb', line 88

def self.loops_root=(loops_root)
  @@loops_root = root.join(loops_root) if loops_root
end

.pid_filePathname

Get the loops monitor process pid file path.

Returns:

  • (Pathname)

    the loops monitor process pid file path.



97
98
99
# File 'lib/loops.rb', line 97

def self.pid_file
  @@pid_file ||= root.join('loops.pid')
end

.pid_file=(pid_file) ⇒ Pathname

Set the loops monitor pid file path.

This is internal method used to set the loops monitor pid file path.

Parameters:

  • path (String)

    the absolute or relative to the loops monitor pid file.

Returns:

  • (Pathname)

    the loops monitor pid file path.



112
113
114
# File 'lib/loops.rb', line 112

def self.pid_file=(pid_file)
  @@pid_file = root.join(pid_file) if pid_file
end

.rootPathname?

Loops root directory.

Usually it is initialized with framework’s root dir (RAILS_ROOT or MERB_ROOT), but you can specify another directory using command line arguments.

Loops current directory will is set to this value (chdir).

Returns:

  • (Pathname, nil)

    the loops root directory.



23
24
25
# File 'lib/loops.rb', line 23

def self.root
  @@root
end

.root=(path) ⇒ Pathname

Set loops root directory.

This is internal method used to set the loops root directory.

Parameters:

  • path (String)

    the absolute path of the loops root directory.

Returns:

  • (Pathname)

    the loops root directory.



38
39
40
# File 'lib/loops.rb', line 38

def self.root=(path)
  @@root = Pathname.new(path).realpath
end