Как развернуть unicorn через capistrano 3?

Добрый вечер.
Пытаюсь развернуть сайт, мой скрипт капистрано.

gem-ы

gem "capistrano", "~> 3.0.1"
gem "capistrano-rvm", "~> 0.0.3"
gem "capistrano-bundler", "~> 1.0.0"
gem "capistrano-rails", "~> 1.1.0"

gem "unicorn", "~> 4.7.0"


config/unicorn.rb

project_name = 'my_project'
root = "/var/www/#{ project_name }/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.stderr.log"
stdout_path "#{root}/log/unicorn.stdout.log"

listen "#{root}/tmp/sockets/unicorn.sock"
worker_processes 2
timeout 30


config/deploy.rb
set :application, 'my_project'
set :repo_url, 'git@*****************.git'

set :deploy_to, '/var/www/my_project'
set :scm, :git
set :branch, "trunk"


set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

set :rvm_type, :system
set :rvm_ruby_version, '2.0.0-p247@my_gemset'

set :keep_releases, 10

set :rails_env, "production"

namespace :deploy do
  desc 'Restart application'
  task :restart do
    invoke 'deploy:unicorn:restart'
  end

  after :finishing, 'deploy:cleanup'




  namespace :unicorn do
    pid_path = "#{release_path}/tmp/pids"
    unicorn_pid = "#{pid_path}/unicorn.pid"

    def run_unicorn
      execute "cd #{current_path} ; bundle exec unicorn_rails -E #{fetch(:rails_env)}"
    end

    desc 'Start unicorn'
    task :start do
      on roles(:app) do
        run_unicorn
      end
    end

    desc 'Stop unicorn'
    task :stop do
      on roles(:app) do
        if test "[ -f #{unicorn_pid} ]"
          execute :kill, "-QUIT `cat #{unicorn_pid}`"
        end
      end
    end

    desc 'Force stop unicorn (kill -9)'
    task :force_stop do
      on roles(:app) do
        if test "[ -f #{unicorn_pid} ]"
          execute :kill, "-9 `cat #{unicorn_pid}`"
          execute :rm, unicorn_pid
        end
      end
    end

    desc 'Restart unicorn'
    task :restart do
      on roles(:app) do
        if test "[ -f #{unicorn_pid} ]"
          execute :kill, "-USR2 `cat #{unicorn_pid}`"
        else
          run_unicorn
        end
      end
    end
  end

end


выполняю cap staging deploy

получаю

Running cd /var/www/my_project/current ; bundle exec unicorn_rails -E production on 192.168.**.**
DEBUG [829b451b] Command: cd /var/www/my_project/current ; bundle exec unicorn_rails -E production
cap aborted!
cd /var/www/my_project/current ; bundle exec unicorn_rails -E production stdout: Nothing written
cd /var/www/my_project/current ; bundle exec unicorn_rails -E production stderr: Nothing written


В лог файле юникорна:

I, [2013-11-21T16:06:09.816444 #25171] INFO -- : Refreshing Gem list
I, [2013-11-21T16:06:11.380857 #25171] INFO -- : listening on addr=/var/www/my_project/shared/tmp/sockets/unicorn.socket fd=10
I, [2013-11-21T16:06:11.381253 #25171] INFO -- : worker=0 spawning...
I, [2013-11-21T16:06:11.382852 #25171] INFO -- : worker=1 spawning...
I, [2013-11-21T16:06:11.383987 #25174] INFO -- : worker=0 spawned pid=25174
I, [2013-11-21T16:06:11.385567 #25171] INFO -- : master process ready
I, [2013-11-21T16:06:11.388761 #25174] INFO -- : worker=0 ready
I, [2013-11-21T16:06:11.389872 #25177] INFO -- : worker=1 spawned pid=25177
I, [2013-11-21T16:06:11.392553 #25177] INFO -- : worker=1 ready
  • Вопрос задан
  • 4455 просмотров
Пригласить эксперта
Ответы на вопрос 1
Nitrino
@Nitrino
Тоже промучался с этим

1. Вместо unicorn_rails нужно использовать просто unicorn
2. Так же мне помогло указывание пути к rvm
RAILS_ENV=#{fetch(:stage)} /usr/local/rvm/bin/rvm default do
перед bundle
def run_unicorn
      execute cd #{release_path}  && ("RAILS_ENV=#{fetch(:stage)} /usr/local/rvm/bin/rvm default do bundle exec unicorn -E #{fetch(:rails_env)})"
end
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы