Class: Foreman::Engine
- Inherits:
-
Object
- Object
- Foreman::Engine
- Extended by:
- Env, Term::ANSIColor
- Includes:
- Env
- Defined in:
- lib/foreman/engine.rb
Defined Under Namespace
Modules: Env
Constant Summary collapse
- COLORS =
[ cyan, yellow, green, magenta, red, blue, intense_cyan, intense_yellow, intense_green, intense_magenta, intense_red, intense_blue ]
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#procfile ⇒ Object
readonly
Returns the value of attribute procfile.
Attributes included from Env
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(procfile, options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #port_for(process, num, base_port = nil) ⇒ Object
- #start ⇒ Object
Methods included from Env
apply_environment!, error, read_environment, read_environment_files
Constructor Details
#initialize(procfile, options = {}) ⇒ Engine
Returns a new instance of Engine.
23 24 25 26 27 28 29 |
# File 'lib/foreman/engine.rb', line 23 def initialize(procfile, ={}) @procfile = Foreman::Procfile.new(procfile) @directory = [:app_root] || File.(File.dirname(procfile)) @options = @environment = read_environment_files([:env]) @output_mutex = Mutex.new end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
14 15 16 |
# File 'lib/foreman/engine.rb', line 14 def directory @directory end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/foreman/engine.rb', line 15 def @options end |
#procfile ⇒ Object (readonly)
Returns the value of attribute procfile.
13 14 15 |
# File 'lib/foreman/engine.rb', line 13 def procfile @procfile end |
Class Method Details
.load_env!(env_file) ⇒ Object
31 32 33 34 |
# File 'lib/foreman/engine.rb', line 31 def self.load_env!(env_file) @environment = read_environment_files(env_file) apply_environment! end |
Instance Method Details
#port_for(process, num, base_port = nil) ⇒ Object
49 50 51 52 53 |
# File 'lib/foreman/engine.rb', line 49 def port_for(process, num, base_port=nil) base_port ||= 5000 offset = procfile.process_names.index(process.name) * 100 base_port.to_i + offset + num - 1 end |
#start ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/foreman/engine.rb', line 36 def start proctitle "ruby: foreman master" termtitle "#{File.basename(@directory)} - foreman" trap("TERM") { puts "SIGTERM received"; terminate_gracefully } trap("INT") { puts "SIGINT received"; terminate_gracefully } assign_colors spawn_processes watch_for_output watch_for_termination end |