Module: UCB::Webfarm
- Includes:
- UnixEnvironment
- Defined in:
- lib/ucb_webfarm.rb
Overview
Constant Summary collapse
- DEV_INT_ENV =
Webfarm Environments
'dev'
- QA_ENV =
'qa'
- PROD_ENV =
'prod'
- RAILS_DEV_INTEGRATION_ENV =
Rails Environments
'dev_integration'
- RAILS_QUALITY_ASSURANCE_ENV =
'quality_assurance'
- RAILS_PRODUCTION_ENV =
'production'
- RAILS_DEV_INTEGRATION_MIGRATION_ENV =
Rails Migration Environments
'dev_integration_migration'
- RAILS_QUALITY_ASSURANCE_MIGRATION_ENV =
'quality_assurance_migration'
- RAILS_PRODUCTION_MIGRATION_ENV =
'production_migration'
Class Method Summary collapse
- .dev? ⇒ Boolean
-
.dev_int? ⇒ Boolean
Returns
true
for dev webfarm instances. -
.environment ⇒ Object
(also: webfarm_environment)
Returns webfarm environment.
-
.environments ⇒ Object
(also: webfarm_environments)
Returns an
Array
of the Webfarm (not Rails) environments. -
.machines ⇒ Object
An
Array
of all machine names for the environment. -
.prod? ⇒ Boolean
Returns
true
for prod webfarm instances. -
.qa? ⇒ Boolean
Returns
true
for qa webfarm instances. -
.rails_environment ⇒ Object
Returns Rails environment corresponding to the Webfarm environment.
-
.rails_migration_environment ⇒ Object
Returns environment to use for migrations.
- .webfarm? ⇒ Boolean
Methods included from UnixEnvironment
Class Method Details
.dev? ⇒ Boolean
67 68 69 |
# File 'lib/ucb_webfarm.rb', line 67 def dev? environment.nil? end |
.dev_int? ⇒ Boolean
Returns true
for dev webfarm instances
72 73 74 |
# File 'lib/ucb_webfarm.rb', line 72 def dev_int? environment == DEV_INT_ENV end |
.environment ⇒ Object Also known as: webfarm_environment
Returns webfarm environment.
41 42 43 |
# File 'lib/ucb_webfarm.rb', line 41 def environment webfarm_environments.include?(domain_name) ? domain_name : nil end |
.environments ⇒ Object Also known as: webfarm_environments
Returns an Array
of the Webfarm (not Rails) environments.
35 36 37 |
# File 'lib/ucb_webfarm.rb', line 35 def environments @webfarm_environments ||= [DEV_INT_ENV, QA_ENV, PROD_ENV] end |
.machines ⇒ Object
An Array
of all machine names for the environment.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ucb_webfarm.rb', line 51 def machines return [] if win32? if dev? ['localhost'] elsif dev_int? ['webfarm-dev-01', 'webfarm-dev-02'] elsif qa? ['webfarm-qa-01', 'webfarm-qa-02'] elsif prod? ['webfarm-prod-01', 'webfarm-prod-02', 'webfarm-prod-03', 'webfarm-prod-04'] else raise(Exception, "Unrecognized Environment") end end |
.prod? ⇒ Boolean
Returns true
for prod webfarm instances
82 83 84 |
# File 'lib/ucb_webfarm.rb', line 82 def prod? environment == PROD_ENV end |
.qa? ⇒ Boolean
Returns true
for qa webfarm instances
77 78 79 |
# File 'lib/ucb_webfarm.rb', line 77 def qa? environment == QA_ENV end |
.rails_environment ⇒ Object
Returns Rails environment corresponding to the Webfarm environment. Returns ENV_RAILS_DEVELOPMENT unless webfarm?
Raises RuntimeError for unknown environment.
90 91 92 93 94 95 |
# File 'lib/ucb_webfarm.rb', line 90 def rails_environment return RAILS_DEV_INTEGRATION_ENV if dev_int? return RAILS_QUALITY_ASSURANCE_ENV if qa? return RAILS_PRODUCTION_ENV if prod? raise "Unknown webfarm rails_environment '#{environment}'" end |
.rails_migration_environment ⇒ Object
Returns environment to use for migrations. Allows different credentials for migrations than for web app.
99 100 101 102 103 104 |
# File 'lib/ucb_webfarm.rb', line 99 def rails_migration_environment return RAILS_DEV_INTEGRATION_MIGRATION_ENV if dev_int? return RAILS_QUALITY_ASSURANCE_MIGRATION_ENV if qa? return RAILS_PRODUCTION_MIGRATION_ENV if prod? raise "Unknown webfarm rails_migration_environment '#{environment}'" end |
.webfarm? ⇒ Boolean
46 47 48 |
# File 'lib/ucb_webfarm.rb', line 46 def webfarm? machine_name.split('-').first == 'webfarm' end |