LINUX.ORG.RU

Capistrano. Dont know how to build task. И прочее.

 , , , ,


0

1

Доброго времени суток. Есть проблема с деплоем Ruby on Rails приложения. В целом проблемы две:

  • 1 - проблема с хуками, before\after
  • 2 - если временно исключить хуки, то при cap deploy: «undefined local variable or method `tasks_without_stage_dependecy`»

И так к нашим кроликам: Файл Capfile

#load 'deploy'
# Uncomment if you are using Rails' asset pipeline
    # load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy.rb' # remove this line to skip loading any of the default tasks

Файл deploy.rb:


hz_config =
    {:name => "www.example.com",
     :domain => "www.example.com",
     :path => "www.example.com",
     :gitname => "example.git",
     :shared_paths => {"import" => "tmp/import"}}

set :application, hz_config[:name]

# set :default_environment, {
#   'PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p194/bin:$PATH",
#   'RUBY_VERSION' => 'ruby 1.9.3',
#   'GEM_HOME'     => '/usr/local/rvm/gems/ruby-1.9.3-p194/',
#   'GEM_PATH'     => '/usr/local/rvm/gems/ruby-1.9.3-p194/',
#   'BUNDLE_PATH'  => '/usr/local/rvm/gems/ruby-1.9.3-p194/'  # If you are using bundler.
# }

set :rvm_ruby_string, '1.9.3' # you probably have this already
set :rvm_type, :system # this is the money config, it defaults to :system

# Deploy to & branch
#set :deploy_to, "/home/webmaster/#{hz_config[:path]}/rails"
#set :branch, "master"

set :deploy_to, "/home/webmaster/#{hz_config[:path]}/test"
set :branch, "development"

# Path settings
set :mongrel_conf, "#{current_path}/config/thin_cluster.yml"

# SSH and Network settings
#default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true, :port => '1234' }
set :user, "webmaster1234"
set :use_sudo, false

#role :app, %w{example.com}
#role :web, %w{example.com}
#role :db,  %w{example.com}

after 'deploy:setup', 'custom:create_shared_directories'

namespace :deploy do
  task :start do
    run "thin start -C#{mongrel_conf}"
  end
  task :stop do
    run "thin start -C#{mongrel_conf}"
  end
  task :restart do
    run "thin restart -C#{mongrel_conf} --onebyone"
  end

end

namespace :customs do
  task :setup do

  end
  # create directories for images
  desc "Create directories for images"
  task :create_shared_directories do
    on roles(:all) do |host|
      hz_config[:shared_paths].each do |shared, real|
        mkdir "-p #{shared_path}/#{shared}"
      end
    end
  end

# make the symlink for public/uploads
  desc "Make the symlink for public/uploads"
  task :make_public_images_files do
    on roles(:all) do |host|
      hz_config[:shared_paths].each do |shared, real|
        rm "-rf #{release_path}/#{real}"
        ln "-fs #{shared_path}/#{shared} #{release_path}/#{real}"
      end
    end
  end

  desc "Copy config cluster files"
  task :copy_configs do
    on roles(:all) do |host|
      cp "#{shared_path}/config/database.yml #{release_path}/config"
      cp "#{shared_path}/config/thin_cluster.yml #{release_path}/config"
    end
  end
#after "deploy:update_code", :copy_configs

  desc "Compile assets"
  task :pipeline_precompile do
    on roles(:all) do |host|
      cd '#{release_path}' && "#{rake} assets:precompile RAILS_ENV=#{rails_env}"
    end
  end
end

Файл deploy/staging.rb:

server 'example.com', roles: [:web, :app, :db]

# GIT
set :scm, "git"
set :repository, "user@host.com/~/git/#{hz_config[:gitname]}"
set :deploy_via, :remote_cache
set :git_shallow_clone, 1
set :copy_exclude, [".git", ".gitignore"]
set :keep_releases, 3

Вывод команд:

rails -v
Rails 3.2.3

gem list 
...
capistrano (3.0.0)
capistrano-ext (1.2.1)
...

Проблема в том что если использовать хуки, при cap deploy жалуется «Dont know how to build task %hook name%. Если же закомментировать строчки с вызовом хуков - „undefined local variable or method `tasks_without_stage_dependecy`“

Все это безобразие настраивается на Windows 7 к сожалению, ну тут уж корпоративная политика, поделать ничего не могу. Работает в рамках RailsInstaller.

Вот такая вот проблема. Заранее спасибо за помощь.



Последнее исправление: gudron (всего исправлений: 1)

after 'deploy:setup','custom:create_shared_directories'
namespace :customs

Ненайденное имя/метод/переменная - 90% опечатка.

special-k ★★★
()
Последнее исправление: special-k (всего исправлений: 2)
Ответ на: комментарий от special-k

Узнай откуда, создай раз просит.

Не думаю что ее нужно создавать в deploy.rb. Полный вывод ошибки: „undefined local variable or method `tasks_without_stage_dependency`“ for #<Capistrano::Aplication:0x2568858>

gudron
() автор топика
Ответ на: комментарий от special-k

Плюнул на 3 версию

В итоге плюнул на capistrano 3.Поставил gem rvm-capistrano и переписал чуток deploy.rb

Щас появилась проблема когда идет выгрузка из git.

Ошибка вида: error reading response length from authentication socket.

Тоесть капистрана запрашивает пароль ssh от git репозитория, после делает git ls-remote, который успешно выполняется и после пытаясь выполнить какой-то набор команд на непосредственно изъятия из git, спотыкается на ошибке указанной выше, и после вываливает permission denied

gudron
() автор топика
Ответ на: комментарий от special-k

не похоже, если запустить депой с сервера на который делается деплой , таже ситуация.

авторизация и так по ключам.

ошибка :

* executing "if [ -d /home/webmaster/example.com/test/shared/cached-copy ]; then cd /home/webmaster/example.com/test/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 94bc04b1f7793abf1b9f789328aac3af072941d5 && git clean -q -d -x -f; else git clone -q -b development --depth 1 ssh://user@git.repostiory.com/~/git/example.git /home/webmaster/example.com/test/shared/cached-copy && cd /home/webmaster/example.com/test/shared/cached-copy && git checkout -q -b deploy 94bc04b1f7793abf1b9f789328aac3af072941d5; fi"
    servers: ["example.com"]
    [example.com] executing command
 ** [example.com :: err] Error reading response length from authentication socket.
 ** [example.com :: err] Permission denied, please try again.
 ** [example.com :: err] Permission denied, please try again.
 ** [example.com :: err] Permission denied (publickey,password).
 ** [example.com :: err] fatal: The remote end hung up unexpectedly
    command finished in 840ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/webmaster/example.com/test/current; true"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 257ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.3' -c 'if [ -d /home/webmaster/example.com/test/shared/cached-copy ]; then cd /home/webmaster/example.com/test/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 94bc04b1f7793abf1b9f789328aac3af072941d5 && git clean -q -d -x -f; else git clone -q -b development --depth 1 ssh://user@git.repository.com/~/git/example.git /home/webmaster/example.com/test/shared/cached-copy && cd /home/webmaster/example.com/test/shared/cached-copy && git checkout -q -b deploy 94bc04b1f7793abf1b9f789328aac3af072941d5; fi'" on e-odin.ru

gudron
() автор топика
Ответ на: комментарий от gudron

Написана же команда, которая выполняется, выполни ее последовательно вручную.

special-k ★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.