使用Capifony部署Symfony2

时间:2013-06-25 12:09:23

标签: symfony deployment capistrano capifony

我在使用capifony将symfony2应用程序部署到我的服务器时遇到问题。我试着直接将git拉到我的服务器上,这样可行。

这是我的deploy.rb文件

# Sylius default deployment configuration.

# Capifony documentation: http://capifony.org
# Capistrano documentation: https://github.com/capistrano/capistrano/wiki

# Be more verbose by uncommenting the following line
# logger.level = Logger::MAX_LEVEL

set :application, "myapp"
set :domain,      "xx.xx.xx.xx"
set :deploy_to,   "/home/user"
set :user,        "user"

role :web,        domain
role :app,        domain
role :db,         domain, :primary => true

set :scm,         :git
set :repository,  "user@xxx.xxx.xxx.xx:/var/www/user/user.git"
set :branch,      "master"
set :deploy_via,  :remote_cache

ssh_options[:forward_agent] = true

set :use_composer,   true
set :update_vendors, true

set :dump_assetic_assets, true

set :writable_dirs,     ["app/cache", "app/logs"]
set :webserver_user,    "www-data"
set :permission_method, :acl

set :shared_files,    ["app/config/parameters.yml", "web/.htaccess", "web/robots.txt"]
set :shared_children, ["app/logs"]

set :model_manager, "doctrine"

set :use_sudo,    false

set :keep_releases, 3


before 'symfony:composer:update', 'symfony:copy_vendors'

namespace :symfony do
  desc "Copy vendors from previous release"
  task :copy_vendors, :except => { :no_release => true } do
    if Capistrano::CLI.ui.agree("Do you want to copy last release vendor dir then do composer install ?: (y/N)")
      capifony_pretty_print "--> Copying vendors from previous release"

      run "cp -a #{previous_release}/vendor #{latest_release}/"
      capifony_puts_ok
    end
  end
end

after "deploy:update", "deploy:cleanup"
after "deploy", "deploy:set_permissions"

这是我的错误

failed: "sh -c 'if [ -d /home/user/shared/cached-copy ]; then cd /home/user/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard f90495dc7d5c62d1bc61415b5c10b762a7e96ee6 && git clean -q -d -x -f; else git clone -q -b master user@xx.xx.xx.xx:/var/www/user/user.git /home/user/shared/cached-copy && cd /home/user/shared/cached-copy && git checkout -q -b deploy f90495dc7d5c62d1bc61415b5c10b762a7e96ee6; fi'" on xxx.xxx.xxx.xxx

我也尝试直接通过ssh在我的服务器上运行它,并且效果很好。

有什么想法吗?日Thnx

1 个答案:

答案 0 :(得分:1)

您似乎没有设置SSH密码。要么将设置放在deploy.rb(不推荐)中,要么让capifony向您询问:

#set :password,    "password"             # the ssh password 
set(:password){ Capistrano::CLI.password_prompt("Type your SSH password for user \"#{user}\": ") }

如果使用logger.level中的deploy.rb设置提高日志详细级别,则可以更轻松地找到导致部署失败的原因。

# IMPORTANT = 0
# INFO      = 1
# DEBUG     = 2
# TRACE     = 3
# MAX_LEVEL = 3
logger.level = Logger::MAX_LEVEL

documentation