0

我似乎在将 Symfony 2 应用程序的 Capifony 部署到按预期工作的远程服务器上时遇到问题。运行后

cap deploy

capifony 的输出表明部署成功,但是当我查看远程服务器上的应用程序文件夹时,没有“当前”符号链接,并且发布文件夹为空。

以下是一些有用的初步信息:

  • 远程和本地部署服务器正在运行 CentOS 6.4
  • 本地部署服务器 Ruby 版本为 1.8.7
  • Capistrano 版本是 2.15.5
  • 应用程序 Symfony 2.2 版
  • 我正在使用部署到登台环境的多级插件

这是我的 deploy.rb 文件的内容:

应用程序/配置/部署.rb

set :stages,        %w(production staging)
set :default_stage, "staging"
set :stage_dir,     "app/config"
require 'capistrano/ext/multistage'

set :application, "mysite"
set :user, "deploy"
set :group, "users"

set :shared_files,      ["app/config/parameters.yml","composer.phar"]
set :shared_children,     [app_path + "/logs", web_path + "/uploads", "vendor"]
set :use_composer, true
set :update_vendors, true
set :copy_vendors, true
set :composer_options, "--no-dev --verbose --prefer-dist --optimize-autoloader"
set :dump_assetic_assets,   true
set :symfony_env_prod, "test"

set :writable_dirs,       ["app/cache"]
set :webserver_user,      "apache"
set :permission_method,   :chmod
set :use_set_permissions, false

default_run_options[:pty] = true
default_run_options[:shell] = true
set  :use_sudo,   false
set :repository,  "git@bitbucket.org:repo/mysite.git"
set :branch, "develop"
set :scm,         :git

set :model_manager, "doctrine"

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

set :app_path,    "app"

set  :keep_releases,  3
set  :deploy_via,  :remote_cache
set(:deploy_to) { "/var/www/#{domain}/" }

# Tasks
namespace :post_deployment do
  desc "Set the right file permissions / ownership for deployed files"
  task :app_permissions, :roles => :app do
   run "#{sudo} chown -Rf apache.users #{deploy_to}"
   run "#{sudo} chmod 775 -Rf #{deploy_to}"
   run "#{sudo} chmod 777 -hRf #{deploy_to}/app/cache"
  end
end

after "post_deployment:app_permissions","deploy:cleanup"
logger.level = Logger::MAX_LEVEL

这是我的 staging.rb 文件的内容:

应用程序/config/staging.rb

server 'staging.mysite.com', :app, :web, :primary => true

set :domain,      "staging.#{application}.com"

这是我从部署过程中得到的输出:

上限部署的输出

[deploy@a mysite]]$ cap deploy    
    triggering load callbacks
  * 2013-08-04 16:20:09 executing `staging'
    triggering start callbacks for `deploy'
  * 2013-08-04 16:20:09 executing `multistage:ensure'
  * 2013-08-04 16:20:09 executing `deploy'
  * 2013-08-04 16:20:09 executing `deploy:update'
 ** transaction: start
  * 2013-08-04 16:20:09 executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
--> Updating code base with checkout strategy
    executing locally: "git ls-remote git@bitbucket.org:repo/mysite.git develop"
    command finished in 2120ms
  * executing "git clone -q -b develop git@bitbucket.org:repo/mysite.git /var/www/staging.mysite.com/releases/20130804152011 && cd /var/www/staging.mysite.com/releases/20130804152011 && git checkout -q -b deploy 643def41fb76916aebccae9cb7dd87a82f7227d9 && (echo 643def41fb76916aebccae9cb7dd87a82f7227d9 > /var/www/staging.mysite.com/releases/20130804152011/REVISION)"
    servers: ["staging.mysite.com"]
Password:
    [staging.mysite.com] executing command
    command finished in 140ms
  * 2013-08-04 16:20:17 executing `deploy:finalize_update'
  * executing "chmod -R g+w /var/www/staging.mysite.com/releases/20130804152011"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 138ms
--> Creating cache directory
  * executing "sh -c 'if [ -d /var/www/staging.mysite.com/releases/20130804152011/app/cache ] ; then rm -rf /var/www/staging.mysite.com/releases/20130804152011/app/cache; fi'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 138ms
  * executing "sh -c 'mkdir -p /var/www/staging.mysite.com/releases/20130804152011/app/cache && chmod -R 0777 /var/www/staging.mysite.com/releases/20130804152011/app/cache'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 216ms
  * executing "chmod -R g+w /var/www/staging.mysite.com/releases/20130804152011/app/cache"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 137ms
  * 2013-08-04 16:20:17 executing `deploy:share_childs'
--> Creating symlinks for shared directories
  * executing "mkdir -p /var/www/staging.mysite.com/shared/app/logs"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
  * executing "sh -c 'if [ -d /var/www/staging.mysite.com/releases/20130804152011/app/logs ] ; then rm -rf /var/www/staging.mysite.com/releases/20130804152011/app/logs; fi'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
  * executing "ln -nfs /var/www/staging.mysite.com/shared/app/logs /var/www/staging.mysite.com/releases/20130804152011/app/logs"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 138ms
  * executing "mkdir -p /var/www/staging.mysite.com/shared/web/uploads"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 136ms
  * executing "sh -c 'if [ -d /var/www/staging.mysite.com/releases/20130804152011/web/uploads ] ; then rm -rf /var/www/staging.mysite.com/releases/20130804152011/web/uploads; fi'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 140ms
  * executing "ln -nfs /var/www/staging.mysite.com/shared/web/uploads /var/www/staging.mysite.com/releases/20130804152011/web/uploads"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 137ms
  * executing "mkdir -p /var/www/staging.mysite.com/shared/vendor"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 137ms
  * executing "sh -c 'if [ -d /var/www/staging.mysite.com/releases/20130804152011/vendor ] ; then rm -rf /var/www/staging.mysite.com/releases/20130804152011/vendor; fi'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
  * executing "ln -nfs /var/www/staging.mysite.com/shared/vendor /var/www/staging.mysite.com/releases/20130804152011/vendor"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 142ms
--> Creating symlinks for shared files
  * executing "mkdir -p /var/www/staging.mysite.com/shared/app/config"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 142ms
  * executing "touch /var/www/staging.mysite.com/shared/app/config/parameters.yml"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 137ms
  * executing "ln -nfs /var/www/staging.mysite.com/shared/app/config/parameters.yml /var/www/staging.mysite.com/releases/20130804152011/app/config/parameters.yml"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
  * executing "mkdir -p /var/www/staging.mysite.com/shared"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 137ms
  * executing "touch /var/www/staging.mysite.com/shared/composer.phar"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 140ms
  * executing "ln -nfs /var/www/staging.mysite.com/shared/composer.phar /var/www/staging.mysite.com/releases/20130804152011/composer.phar"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 138ms
--> Normalizing asset timestamps
  * executing "find /var/www/staging.mysite.com/releases/20130804152011/web/css /var/www/staging.mysite.com/releases/20130804152011/web/images /var/www/staging.mysite.com/releases/20130804152011/web/js -exec touch -t 201308041520.20 {} ';' &> /dev/null || true"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 140ms
    triggering after callbacks for `deploy:finalize_update'
  * 2013-08-04 16:20:20 executing `symfony:composer:install'
    triggering before callbacks for `symfony:composer:install'
  * 2013-08-04 16:20:20 executing `symfony:composer:get'
  * executing "if [ -e /var/www/staging.mysite.com/releases/20130804152011/composer.phar ]; then echo 'true'; fi"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
--> Downloading Composer
  * executing "sh -c 'cd /var/www/staging.mysite.com/releases/20130804152011 && curl -s http://getcomposer.org/installer | php'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
--> Installing Composer dependencies
  * executing "sh -c 'cd /var/www/staging.mysite.com/releases/20130804152011 && php composer.phar install --no-dev --verbose --prefer-dist --optimize-autoloader'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
  * 2013-08-04 16:20:20 executing `symfony:composer:dump_autoload'
--> Dumping an optimized autoloader
  * executing "sh -c 'cd /var/www/staging.mysite.com/releases/20130804152011 && php composer.phar dump-autoload --optimize'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 137ms
  * 2013-08-04 16:20:20 executing `symfony:cache:warmup'
--> Warming up cache
  * executing "sh -c 'cd /var/www/staging.mysite.com/releases/20130804152011 && php app/console cache:warmup --env=test --no-debug'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 138ms
  * executing "chmod -R g+w /var/www/staging.mysite.com/releases/20130804152011/app/cache"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 139ms
  * 2013-08-04 16:20:21 executing `symfony:project:clear_controllers'
--> Clear controllers
  * executing "sh -c 'cd /var/www/staging.mysite.com/releases/20130804152011 && rm -f web/app_*.php'"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 141ms
  * 2013-08-04 16:20:21 executing `deploy:create_symlink'
  * executing "rm -f /var/www/staging.mysite.com/current &&  ln -s /var/www/staging.mysite.com/releases/20130804152011 /var/www/staging.mysite.com/current"
    servers: ["staging.mysite.com"]
    [staging.mysite.com] executing command
    command finished in 138ms
    triggering after callbacks for `deploy:create_symlink'
--> Successfully deployed!
 ** transaction: commit
  * 2013-08-04 16:20:21 executing `deploy:restart'

有没有人对可能发生的事情以及为什么我会得到这个奇怪的结果有任何想法(成功,但没有真正的成功)。我的配置是否有问题可能导致这种情况?任何帮助将非常感激。

4

2 回答 2

1

莫非是远程缓存有问题?尝试注释掉这一行:

set  :deploy_via,  :remote_cache

此外,请尝试禁用:post_deployment有关设置正确权限的命令,以隔离​​导致问题的配置部分。

希望这可以帮助...

于 2013-08-04T19:08:47.823 回答
1

它是否对远程服务器进行了任何更改?

您能否使用您自己提供给 capifony 的详细信息成功地通过 SSH 连接到远程服务器并进行 capifony 所做的各种更改?

我们的服务器不允许某些用户使用 SSH。您可以通过 ssh 登录,但没有得到 shell,只是一条提示您不允许登录的消息。 Capifony 没有将其识别为错误,将所有命令都发送给它,但没有收到任何错误回复,并假设一切都很好。事实上什么也没发生。请参阅此错误报告,尽管我不确定 capifony 可以做什么来解决该问题。

于 2013-09-03T09:27:13.827 回答