Sha256: a6b37ab4ed75ad6fdbd0d248c17f7d07cc492fe446a691811a3baddf0c1ff40a

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

set :server_name, ->{ fetch(:application) }
set :nginx_proxy_read_timeout, '60s'

namespace :nginx do
  desc "Installs nginx on all app servers"
  task :install do
    on roles(:app) do |host|
      execute :sudo, "apt-get -y update"
      execute :sudo, "apt-get -y install nginx"
    end
  end

  %w[start stop restart].each do |command|
    desc "#{command} nginx"
    task command do
      on roles :app do
        as :root do
          execute :service, "nginx #{command}"
        end
      end
    end
  end
end

namespace :nginx do
  namespace :rainbows do
    desc "Setup nginx configuration for this application (rainbows)"
    task :setup do
      on roles :web do
        template "nginx_rainbows.erb", "/tmp/nginx_conf"

        as :root do
          execute :mv, "/tmp/nginx_conf /etc/nginx/sites-enabled/#{fetch(:application)}"
          execute :rm, "-f /etc/nginx/sites-enabled/default"
        end
      end
      after 'nginx:rainbows:setup', 'nginx:restart'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-devops-0.0.12 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.11 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.10 lib/capistrano/tasks/nginx.rake