Class: Rsm::Install::Nginx
- Defined in:
- lib/tasks/install/nginx.rb
Constant Summary
Constants inherited from Base
Constants included from Actions
Instance Attribute Summary collapse
-
#auth_basic ⇒ Object
readonly
Returns the value of attribute auth_basic.
-
#auth_basic_realm ⇒ Object
readonly
Returns the value of attribute auth_basic_realm.
-
#auth_basic_user_file ⇒ Object
readonly
Returns the value of attribute auth_basic_user_file.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#rewrite_www ⇒ Object
readonly
Returns the value of attribute rewrite_www.
-
#upstream_name ⇒ Object
readonly
Returns the value of attribute upstream_name.
Attributes inherited from Base
#server, #socket_per_worker, #worker_processes
Instance Method Summary collapse
- #enable_nginx_site ⇒ Object
- #nginx_config_include_vhosts ⇒ Object
- #nginx_server_config ⇒ Object
- #set_destination_root ⇒ Object
Methods inherited from Base
#set_server, #set_worker_processes, source_root, template_path
Methods included from Actions
#application_root, #downloaded_file, #fetch_temporary_archive, #ruby_binary, #run_ruby_binary, #run_with_bundler, #unpack_compressed_archive
Instance Attribute Details
#auth_basic ⇒ Object (readonly)
Returns the value of attribute auth_basic.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def auth_basic @auth_basic end |
#auth_basic_realm ⇒ Object (readonly)
Returns the value of attribute auth_basic_realm.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def auth_basic_realm @auth_basic_realm end |
#auth_basic_user_file ⇒ Object (readonly)
Returns the value of attribute auth_basic_user_file.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def auth_basic_user_file @auth_basic_user_file end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def domain @domain end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def environment @environment end |
#rewrite_www ⇒ Object (readonly)
Returns the value of attribute rewrite_www.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def rewrite_www @rewrite_www end |
#upstream_name ⇒ Object (readonly)
Returns the value of attribute upstream_name.
4 5 6 |
# File 'lib/tasks/install/nginx.rb', line 4 def upstream_name @upstream_name end |
Instance Method Details
#enable_nginx_site ⇒ Object
45 46 47 |
# File 'lib/tasks/install/nginx.rb', line 45 def enable_nginx_site link_file "#{destination_root}/sites-available.d/#{domain}.conf", "sites-enabled.d/#{domain}.conf" unless FileTest.symlink?("#{destination_root}/sites-enabled.d/#{domain}.conf") end |
#nginx_config_include_vhosts ⇒ Object
18 19 20 21 22 23 |
# File 'lib/tasks/install/nginx.rb', line 18 def nginx_config_include_vhosts include_str = "include sites-enabled.d/*.conf;" unless File.read("#{destination_root}/nginx.conf").include?(include_str) inject_into_file "nginx.conf", "#{include_str}\n", :after => "index index.html;\n" end end |
#nginx_server_config ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tasks/install/nginx.rb', line 25 def nginx_server_config @environment = [:environment] @domain = [:domain] unless @domain @domain = `hostname -f`.strip @domain = "#{name}.#{@domain}" end @rewrite_www = [:rewrite_www] @auth_basic = [:auth_basic] @auth_basic_realm = [:auth_basic_realm] @auth_basic_realm = name.to_s.capitalize unless @auth_basic_realm @auth_basic_user_file = [:auth_basic_user_file] @upstream_name = "#{domain}_server" template "nginx-server.conf.erb", "sites-available.d/#{domain}.conf" end |
#set_destination_root ⇒ Object
14 15 16 |
# File 'lib/tasks/install/nginx.rb', line 14 def set_destination_root self.destination_root = [:nginx_root] end |