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.



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

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.



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

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.



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

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.



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

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:



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

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

.logger=(logger) ⇒ Object

Set the current loops logger.



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

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

.loops_rootPathname

Get directory containing loops classes.

Returns:

  • (Pathname)

    the loops directory path.



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

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.



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

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.



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

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.



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

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. Default: current directory.

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

Returns:

  • (Pathname)

    the loops root directory.



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

def self.root
  @@root ||= Pathname.new('').realpath
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.



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

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

.running?Boolean

Returns true if current process is started with loops CLI

Returns:

  • (Boolean)


169
170
171
# File 'lib/loops.rb', line 169

def self.running?
  Loops::CLI.running?
end