我似乎在将Symfony 2应用程序的Capifony部署到远程服务器上时遇到了问题。运行后
cap deploy
capifony的输出表明部署成功,但是当我查看远程服务器上的应用程序文件夹时,没有“当前”符号链接,并且releases文件夹为空。
以下是一些有用的初步信息:
以下是我的deploy.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文件的内容:
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'
有没有人对可能发生的事情以及为什么我得到这种奇怪的结果(成功,但没有真正的成功)有任何想法。我的配置有什么问题可能会导致这种情况吗?任何帮助将不胜感激。
答案 0 :(得分:1)
是否存在远程缓存问题?尝试评论该行:
set :deploy_via, :remote_cache
此外,尝试禁用:post_deployment
命令设置正确的权限,以隔离导致问题的配置部分。
希望这会有所帮助......
答案 1 :(得分:1)
是否对远程服务器进行了任何更改?
您是否可以使用自己给予自我保护的详细信息成功通过SSH连接到远程服务器,并进行类型所做的更改?
我们有一台服务器禁止某些用户使用SSH。你可以ssh,但你没有得到一个shell,只是一条你不被允许登录的消息.Capifony没有认识到这是一个错误,发送了所有命令,没有得到任何错误,并假设一切都很好。事实上什么也没发生过。请参阅this bug report,虽然我不确定能够解决问题的能力是什么。