Sha256: f048e0ab6fffe842b44fdfdfb3cfc8337fd9da7e7f956c24566b16026545f218

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

namespace :unicorn do
  desc 'Unicorn setup'
  task :setup do
    set :unicorn_user, fetch(:local_user)
    set :unicorn_user_group, fetch(:local_user_group)
    set :unicorn_config, "#{fetch(:shared_path)}/config/unicorn.rb"
    set :unicorn_log, "#{fetch(:shared_path)}/log/unicorn.log"
    set :unicorn_workers, 2

    on roles(:app) do
      execute "mkdir -p #{fetch(:shared_path)}/config"
      template 'unicorn.rb.erb', fetch(:unicorn_config)
      template 'unicorn_init.erb', "#{fetch(:shared_path)}/config/unicorn_init.sh"
      execute "chmod +x #{fetch(:shared_path)}/config/unicorn_init.sh"
      sudo "ln -nfs #{fetch(:shared_path)}/config/unicorn_init.sh /etc/init.d/unicorn_#{fetch(:application)}"
    end
  end

  %w[start stop restart].each do |command|
    desc "Unicorn server #{command}."
    task command do
      on roles(:app), in: :groups, limit: 3, wait: 4 do
        execute "/etc/init.d/unicorn_#{fetch(:application)} #{command}"
      end
    end
  end

  desc "Unicorn server upgrade."
  task :upgrade do
    on roles(:app), in: :groups, limit: 3, wait: 1 do
      execute "/etc/init.d/unicorn_#{fetch(:application)} upgrade"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
recipes_matic-1.3.0 lib/generators/recipes_matic/templates/lib/capistrano/tasks/unicorn.rake
recipes_matic-1.2.1 lib/generators/recipes_matic/templates/lib/capistrano/tasks/unicorn.rake
recipes_matic-1.2.0 lib/generators/recipes_matic/templates/lib/capistrano/tasks/unicorn.rake