Sha256: 14167773511093c0857a283d355d5f50934b23619b542a1346a0518f03e2ebdf

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

namespace :load do
  task :defaults do
    # Nginx and puma configuration
    set :nginx_config_name, -> { "#{fetch(:application)}_#{fetch(:stage)}" }
    set :nginx_sites_available_path, -> { '/etc/nginx/sites-available' }
    set :nginx_sites_enabled_path, -> { '/etc/nginx/sites-enabled' }
    set :nginx_server_name, -> { "localhost #{fetch(:application)}.local" }
    set :nginx_flags, -> { 'fail_timeout=0' }
    set :nginx_http_flags, -> { fetch(:nginx_flags) }
    set :nginx_socket_flags, -> { fetch(:nginx_flags) }
    set :nginx_use_ssl, false
  end
end
namespace :puma do
  desc 'Setup nginx configuration'
  task :nginx_config do
    on roles(fetch(:puma_nginx, :web)) do |role|
      puma_switch_user(role) do
        template_puma('nginx_conf', "/tmp/nginx_#{fetch(:nginx_config_name)}", role)
        sudo :mv, "/tmp/nginx_#{fetch(:nginx_config_name)} #{fetch(:nginx_sites_available_path)}/#{fetch(:nginx_config_name)}"
        sudo :ln, '-fs', "#{fetch(:nginx_sites_available_path)}/#{fetch(:nginx_config_name)} #{fetch(:nginx_sites_enabled_path)}/#{fetch(:nginx_config_name)}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
capistrano3-puma-2.0.0 lib/capistrano/tasks/nginx.rake
capistrano-puma-a-2.0.0 lib/capistrano/tasks/nginx.rake