1

我正在尝试使用 capifony 进行部署,但是当我运行时

$ cap deploy

它返回一个错误

--> Updating code base with remote_cache strategy
Password: 
--> Creating cache directory................................✔
--> Creating symlinks for shared directories................✔
--> Creating symlinks for shared files......................✔
--> Normalizing asset timestamps............................✔
--> Updating Composer.......................................✔
--> Updating Composer dependencies..........................✘
*** [err :: som.info] 
*** [err :: som.info] [RuntimeException]
*** [err :: som.info] An error occurred when executing the "'cache:clear --no-warmup'" command.

*** [err :: som.info] Exception trace:
*** [err :: som.info] () at /home/yamaken/som.info/shared/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:182
*** [err :: som.info] Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeCommand() at /home/yamaken/som.info/shared/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:62

.....

这是我的deploy.rb

set :application, "sommelier"
set :domain,      "som.info"
set :deploy_to,   "/home/yamaken/#{domain}"
set :app_path,    "app"

set :repository,  "git@github.com:haji/sommelier.git"
set :scm,         :git

set :default_shell,         "TERM=dumb sudo -u yamaken /bin/sh"

set :branch, "master"

set :scm_username, "haji"
set :scm_passphrase, "********"

set   :use_sudo,      false

set :user, 'yamaken'

set :model_manager, "doctrine"
# Or: `propel`

role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain, :primary => true       # This may be the same as your `Web` server

set  :keep_releases,  3
set :shared_files,        ["app/config/parameters.yml"]
set :shared_children,     [app_path + "/spool",app_path + "/logs", web_path + "/uploads","vendor"]


set :writable_dirs,       ["app/cache", "app/logs","app/spool"]
set :permission_method,   :chown #
set :use_set_permissions, false

我已经根据@nifr 的建议尝试了代码。

$ _DEBUG=1 cap deploy
Ruby Version                      => 1.8.7-p358
OpenSSL::Version                  => OpenSSL 0.9.8y 5 Feb 2013
Net::SSH::Version::CURRENT        => 2.6.8
Net::SSH -> Local platform        => unix
Password: 
Remote Whoami                     => yamaken
umask on Server                   => 0022
$SHELL                            => /bin/bash
$BASH_VERSION                     => 4.1.5(1)-release
Interactive Shell - Test: $PS1    => no
  * 2013-12-04 11:45:36 executing `deploy'
  * 2013-12-04 11:45:36 executing `deploy:update'
 ** transaction: start
  * 2013-12-04 11:45:36 executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
--> Updating code base with checkout strategy
    executing locally: "git ls-remote git@github.com:haji/sommelier.git master"
    command finished in 2798ms
  * executing "git clone -q -b master git@github.com:haji/sommelier.git /home/yamaken/som.info/releases/20131204024539 && cd /home/yamaken/som.info/releases/20131204024539 && git checkout -q -b deploy 1ab8525ef883da0826b6b3d08a1c98da1904edd2 && (echo 1ab8525ef883da0826b6b3d08a1c98da1904edd2 > /home/yamaken/som.info/releases/20131204024539/REVISION)"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 24263ms
  * 2013-12-04 11:46:03 executing `deploy:finalize_update'
  * executing "chmod -R g+w /home/yamaken/som.info/releases/20131204024539"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 556ms
--> Creating cache directory
  * executing "sh -c 'if [ -d /home/yamaken/som.info/releases/20131204024539/app/cache ] ; then rm -rf /home/yamaken/som.info/releases/20131204024539/app/cache; fi'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 374ms
  * executing "sh -c 'mkdir -p /home/yamaken/som.info/releases/20131204024539/app/cache && chmod -R 0777 /home/yamaken/som.info/releases/20131204024539/app/cache'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 383ms
  * executing "chmod -R g+w /home/yamaken/som.info/releases/20131204024539/app/cache"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 365ms
  * 2013-12-04 11:46:05 executing `deploy:share_childs'
--> Creating symlinks for shared directories
  * executing "mkdir -p /home/yamaken/som.info/shared/app/spool"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 370ms
  * executing "sh -c 'if [ -d /home/yamaken/som.info/releases/20131204024539/app/spool ] ; then rm -rf /home/yamaken/som.info/releases/20131204024539/app/spool; fi'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 373ms
  * executing "ln -nfs /home/yamaken/som.info/shared/app/spool /home/yamaken/som.info/releases/20131204024539/app/spool"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 372ms
  * executing "mkdir -p /home/yamaken/som.info/shared/app/logs"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 369ms
  * executing "sh -c 'if [ -d /home/yamaken/som.info/releases/20131204024539/app/logs ] ; then rm -rf /home/yamaken/som.info/releases/20131204024539/app/logs; fi'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 366ms
  * executing "ln -nfs /home/yamaken/som.info/shared/app/logs /home/yamaken/som.info/releases/20131204024539/app/logs"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 376ms
  * executing "mkdir -p /home/yamaken/som.info/shared/web/uploads"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 373ms
  * executing "sh -c 'if [ -d /home/yamaken/som.info/releases/20131204024539/web/uploads ] ; then rm -rf /home/yamaken/som.info/releases/20131204024539/web/uploads; fi'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 401ms
  * executing "ln -nfs /home/yamaken/som.info/shared/web/uploads /home/yamaken/som.info/releases/20131204024539/web/uploads"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 375ms
  * executing "mkdir -p /home/yamaken/som.info/shared/vendor"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 375ms
  * executing "sh -c 'if [ -d /home/yamaken/som.info/releases/20131204024539/vendor ] ; then rm -rf /home/yamaken/som.info/releases/20131204024539/vendor; fi'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 969ms
  * executing "ln -nfs /home/yamaken/som.info/shared/vendor /home/yamaken/som.info/releases/20131204024539/vendor"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 366ms
--> Creating symlinks for shared files
  * executing "mkdir -p /home/yamaken/som.info/shared/app/config"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 366ms
  * executing "touch /home/yamaken/som.info/shared/app/config/parameters.yml"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 378ms
  * executing "ln -nfs /home/yamaken/som.info/shared/app/config/parameters.yml /home/yamaken/som.info/releases/20131204024539/app/config/parameters.yml"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 393ms
--> Normalizing asset timestamps
  * executing "find /home/yamaken/som.info/releases/20131204024539/web/css /home/yamaken/som.info/releases/20131204024539/web/images /home/yamaken/som.info/releases/20131204024539/web/js -exec touch -t 201312040246.11 {} ';' &> /dev/null || true"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 383ms
    triggering after callbacks for `deploy:finalize_update'
  * 2013-12-04 11:46:12 executing `symfony:cache:warmup'
--> Warming up cache
  * executing "sh -c 'cd /home/yamaken/som.info/releases/20131204024539 && php app/console cache:warmup --env=prod --no-debug'"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 530ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/yamaken/som.info/releases/20131204024539; true"
    servers: ["som.info"]
    [som.info] executing command
    command finished in 536ms
failed: "TERM=dumb sudo -u yamaken /bin/sh -c 'sh -c '\\''cd /home/yamaken/som.info/releases/20131204024539 && php app/console cache:warmup --env=prod --no-debug'\\'''" on som.info

我还有一个问题,部署失败后有没有办法不做下面的行?

executing "rm -rf /home/yamaken/som.info/releases/20131204024539; true"

如果我可以将文件保留在服务器上。我可以通过手动操作检查原因。

4

1 回答 1

2

调试 Capistrano 部署:

我想出的一个简化调试的小技巧是使用环境变量来打开和关闭详细输出和一些额外的信息。

您可以将这样的内容添加到您的deploy.rb(如果您愿意,可以延长或缩短)...

unless ENV['_DEBUG'].nil?
    puts "Ruby Version                      => #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
    puts "OpenSSL::Version                  => #{OpenSSL::OPENSSL_VERSION}"
    puts "Net::SSH::Version::CURRENT        => #{Net::SSH::Version::CURRENT}"
    puts "Net::SSH -> Local platform        => #{Net::SSH::Authentication::PLATFORM}"
    puts "Remote Whoami                     => #{capture 'whoami'}"
    puts "umask on Server                   => #{capture 'umask'}"
    puts "$SHELL                            => #{capture 'echo $SHELL'}"
    puts "$BASH_VERSION                     => #{capture 'echo $BASH_VERSION'}"
    puts "Interactive Shell - Test: $PS1    => #{capture 'if [ -z "$PS1" ]; then echo no; else echo yes; fi'}"

    logger.level =          Logger::MAX_LEVEL
    ssh_options[:verbose] = :debug 
end

现在执行:

_DEBUG=1 cap deploy
于 2013-12-04T00:19:07.837 回答