Class: Capistrano::Nginx

Inherits:
Plugin
  • Object
show all
Defined in:
lib/capistrano/nginx.rb

Defined Under Namespace

Classes: PasswdInteractionHandler

Instance Method Summary collapse

Instance Method Details

#add_sudo_if_required(argument_list, *keys) ⇒ Object

prepend :sudo to list if arguments if :key is in :nginx_use_sudo_for list


29
30
31
32
33
34
35
36
# File 'lib/capistrano/nginx.rb', line 29

def add_sudo_if_required argument_list, *keys
  keys.each do | key |
    if nginx_use_sudo? key
      argument_list.unshift(:sudo)
      break
    end
  end
end

#define_tasksObject


24
25
26
# File 'lib/capistrano/nginx.rb', line 24

def define_tasks
  eval_rakefile File.expand_path('../tasks/nginx.rake', __FILE__)
end

#nginx_use_sudo?(key) ⇒ Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/capistrano/nginx.rb', line 38

def nginx_use_sudo? key
  (fetch(:nginx_sudo_tasks).include?(key) || fetch(:nginx_sudo_paths).include?(key))
end

#set_defaultsObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/capistrano/nginx.rb', line 5

def set_defaults
  set :nginx_sudo_paths,          -> { [:nginx_log_path, :nginx_sites_enabled_dir, :nginx_sites_available_dir] }
  set :nginx_sudo_tasks,          -> { ['nginx:start', 'nginx:stop', 'nginx:restart', 'nginx:reload', 'nginx:configtest', 'nginx:site:add', 'nginx:site:disable', 'nginx:site:enable', 'nginx:site:remove' ] }
  set :nginx_log_path,            -> { "#{shared_path}/log" }
  set :nginx_service_path,        -> { 'service nginx' }
  set :nginx_static_dir,          -> { "public" }
  set :nginx_application_name,    -> { fetch(:application) }
  set :nginx_sites_enabled_dir,   -> { "/etc/nginx/sites-enabled" }
  set :nginx_sites_available_dir, -> { "/etc/nginx/sites-available" }
  set :nginx_roles,               -> { :sudo }
  set :nginx_template,            -> { :default }
  set :nginx_use_ssl,             -> { false }
  set :nginx_ssl_certificate,          -> { "#{fetch(:application)}.crt" }
  set :nginx_ssl_certificate_path,     -> { '/etc/ssl/certs' }
  set :nginx_ssl_certificate_key,      -> { "#{fetch(:application)}.key" }
  set :nginx_ssl_certificate_key_path, -> { '/etc/ssl/private' }
  set :app_server,                     -> { true }
end