Class: NginxStage::AppConfigGenerator

Inherits:
Generator
  • Object
show all
Includes:
AppConfigView
Defined in:
lib/nginx_stage/generators/app_config_generator.rb

Overview

This generator stages and generates the NGINX app config. It is also responsible for reloading the per-user NGINX process after updating the app config.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AppConfigView

#app_passenger_env, #app_request_uri, #app_root, #app_token, #sendfile_root, #sendfile_uri

Methods inherited from Generator

_options, add_hook, add_option, #create_file, desc, #empty_directory, footer, hooks, #initialize, #invoke, options, rem_hook, rem_option, #template

Methods included from GeneratorHelpers

#add_skip_nginx_support, #add_sub_uri_support, #add_user_support

Constructor Details

This class inherits a constructor from NginxStage::Generator

Instance Attribute Details

#envSymbol

The environment the app is run under (parsed from sub_request)

Returns:

  • (Symbol)

    environment app is run under


26
27
28
# File 'lib/nginx_stage/generators/app_config_generator.rb', line 26

def env
  @env
end

#nameString

The name of the app

Returns:

  • (String)

    name of app


34
35
36
# File 'lib/nginx_stage/generators/app_config_generator.rb', line 34

def name
  @name
end

#ownerString

The owner of the app (parsed from sub_request or assume it is user)

Returns:

  • (String)

    owner of app


30
31
32
# File 'lib/nginx_stage/generators/app_config_generator.rb', line 30

def owner
  @owner
end

Instance Method Details

#sub_requestString

The remainder of the request after the sub-uri used to determine the environment and app

Examples:

An app is requested through ‘/pun/usr/user/appname/…’

sub_request #=> "/usr/user/appname/..."

Returns:

  • (String)

    the remainder of the request after sub-uri

Raises:


52
53
54
55
56
57
58
# File 'lib/nginx_stage/generators/app_config_generator.rb', line 52

add_option :sub_request do
  {
    opt_args: ["-r", "--sub-request=SUB_REQUEST", "# The SUB_REQUEST that requests the specified app"],
    required: true
    # sub-request is validated in `NginxStage::parse_app_request`
  }
end