Sha256: 7a0cbe3951b361953a65633f8a861bf617867f02a60e348ff033c1cf9ba9042d

Contents?: true

Size: 1.25 KB

Versions: 11

Compression:

Stored size: 1.25 KB

Contents

require 'capistrano'
require 'kapify/base'

Capistrano::Configuration.instance.load do
  set_default(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
  set_default(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
  set_default(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
  set_default(:unicorn_user) { user }
  set_default(:unicorn_workers) { Capistrano::CLI.ui.ask "Number of unicorn workers: " }

  namespace :kapify do
    namespace :unicorn do
      desc "Setup Unicorn initializer and app configuration"
      task :setup, roles: :app do
        run "mkdir -p #{shared_path}/config"
        kapify_template "unicorn", "unicorn.rb.erb", unicorn_config
        kapify_template "unicorn", "unicorn_init.erb", "/tmp/unicorn_init"
        run "chmod +x /tmp/unicorn_init"
        run "#{sudo} mv /tmp/unicorn_init /etc/init.d/unicorn_#{application}"
        run "#{sudo} update-rc.d -f unicorn_#{application} defaults"
      end

      after "deploy:setup", "kapify:unicorn:setup"

      %w[start stop restart].each do |command|
        desc "#{command} unicorn"
        task command, roles: :app do
          run "service unicorn_#{application} #{command}"
        end

        after "deploy:#{command}", "kapify:unicorn:#{command}"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kapify-0.1.3 lib/kapify/unicorn/configuration.rb
kapify-0.1.2 lib/kapify/unicorn/configuration.rb
kapify-0.1.1 lib/kapify/unicorn/configuration.rb
kapify-0.1.0 lib/kapify/unicorn/configuration.rb
kapify-0.0.16 lib/kapify/unicorn/configuration.rb
kapify-0.0.15 lib/kapify/unicorn/configuration.rb
kapify-0.0.14 lib/kapify/unicorn/configuration.rb
kapify-0.0.13 lib/kapify/unicorn/configuration.rb
kapify-0.0.12 lib/kapify/unicorn/configuration.rb
kapify-0.0.11 lib/kapify/unicorn/configuration.rb
kapify-0.0.10 lib/kapify/unicorn/configuration.rb