I seem to have a problem getting a Capifony deployment of a Symfony 2 application to a remote server working as expected. After running
cap deploy
the output from capifony indicates a successful deployment but when I look in the application folder on the remote server, there is no "current" symlink in place and the releases folder is empty.
Here is some useful preliminary information:
Here are the contents of my deploy.rb file:
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
and here are the contents of my staging.rb file:
server 'staging.mysite.com', :app, :web, :primary => true
set :domain, "staging.#{application}.com"
and here is the output that I get from the deployment process:
[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'
Does anyone have any ideas as to what could be going on and why I'm getting this weird outcome (success, but no real success). Is there something wrong with my configuration that could be resulting in this? Any help would be much appreciated.
Could it be that there is a problem with remote cache? Try commenting out the line:
set :deploy_via, :remote_cache
Also, try disabling :post_deployment
command about setting correct permissions in order to isolate config part that causes problem.
Hope this helps...