Class Foreman::Engine
In: lib/foreman/engine.rb
Parent: Object

Methods

Constants

HANDLED_SIGNALS = [ :TERM, :INT, :HUP, :USR1, :USR2 ]   The signals that the engine cares about.

Attributes

env  [R] 
options  [R] 
processes  [R] 

Public Class methods

Create an Engine for running processes

@param [Hash] options

@option options [String] :formation (all=1) The process formation to use @option options [Fixnum] :port (5000) The base port to assign to processes @option options [String] :root (Dir.pwd) The root directory from which to run processes

Public Instance methods

Get the base port for this foreman instance

@returns [Fixnum] port The base port

Clear the processes registered to this Engine

deprecated

Get the process formation

@returns [Fixnum] The formation count for the specified process

Handle a HUP signal

Handle an INT signal

Invoke the real handler for signal sig. This shouldn‘t be called directly by signal handlers, as it might invoke code which isn‘t re-entrant.

@param [Symbol] sig the name of the signal to be handled

Handle a TERM signal

Send a signal to all processes started by this Engine

@param [String] signal The signal to send to each process

Send a signal to the whole process group.

@param [String] signal The signal to send

Load a .env file into the env for this Engine

@param [String] filename A .env file to load into the environment

Register processes by reading a Procfile

@param [String] filename A Procfile from which to read processes to register

Wake the main thread up via the selfpipe when there‘s a signal

Get the port for a given process and offset

@param [Foreman::Process] process A Process associated with this engine @param [Fixnum] instance The instance of the process

@returns [Fixnum] port The port to use for this instance of this process

Get the Process for a specifid name

@param [String] name The process name

@returns [Foreman::Process] The Process for the specified name

List the available process names

@returns [Array] A list of process names

Register a process to be run by this Engine

@param [String] name A name for this process @param [String] command The command to run @param [Hash] options

@option options [Hash] :env A custom environment for this process

Set up deferred signal handlers

Unregister deferred signal handlers

Get the root directory for this Engine

@returns [String] The root directory

Start the processes registered to this Engine

[Validate]