Sha256: 266ee89436e594736c78952eba8ac6a4027cdd05c233fc1839101d22a325d4fa

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module CapistranoDeployManagement
  module Unicorn
    def self.load_into(configuration)
      configuration.load do

        set(:unicorn_config)  { "#{current_path}/config/unicorn.rb" }
        set(:unicorn_pidfile) { "#{deploy_to}/shared/pids/unicorn.pid" }
        set(:unicorn_pid)     { "cat #{unicorn_pidfile}" }

        namespace :unicorn do
          desc 'Restart unicorn.'
          task :restart, :roles => :app, :except => {:no_release => true} do
            # unicorn.stop
            unicorn.start
          end

          desc 'Start unicorn.'
          task :start, :roles => :app, :except => {:no_release => true} do
            run "cd #{current_path} && unicorn -c #{unicorn_config} -E production -D"
          end

          desc 'Stop unicorn.'
          task :stop, :roles => :app, :except => {:no_release => true} do
            # run "if test -s #{unicorn_pidfile}; then cd #{current_path} && kill $(#{unicorn_pid}) fi"
            # above line fails with error -c: line 1: syntax error: unexpected end of file
            run "cd #{current_path} && kill $(#{unicorn_pid})"
          end
        end

        after 'deploy:restart', 'unicorn:restart'

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-deploy-management-0.1.6 lib/capistrano-deploy-management/unicorn.rb