capifony think i'm using Symfony 1 - symfony

i'm trying to deploy a new site and i don't understand why i have some weird errors.
My first error is:
Users/Epok/.rvm/gems/ruby-1.9.3-p448/gems/capifony-2.2.10/lib/capifony_symfony1.rb:40:in `read': No such file or directory - config/databases.yml (Errno::ENOENT)
from /Users/Epok/.rvm/gems/ruby-1.9.3-p448/gems/capifony-2.2.10/lib/capifony_symfony1.rb:40:in `guess_symfony_orm'
from /Users/Epok/.rvm/gems/ruby-1.9.3-p448/gems/capifony-2.2.10/lib/capifony_symfony1.rb:27:in `block in load'
I don't understand why capifony asking me for database.yml which is a file for Symfony 1 (i think)
So i put : set:use_orm, false (as the documentation say for symfony1 project) and it works but now i have a new error which is :
* executing "sh -c 'cd /usr/share/nginx/www/stackexchange/releases/20130820143357 && php ./symfony cache:clear'"
servers: ["37.187.66.229"]
[37.187.66.229] executing command
** [out :: 37.187.66.229] Could not open input file: ./symfony
command finished in 255ms
*** [deploy:update_code] rolling back
* executing "rm -rf /usr/share/nginx/www/stackexchange/releases/20130820143357; true"
servers: ["37.187.66.229"]
[37.187.66.229] executing command
command finished in 113ms
failed: "sh -c 'sh -c '\\''cd /usr/share/nginx/www/stackexchange/releases/20130820143357 && php ./symfony cache:clear'\\'''" on 37.187.66.229
It's been a long time since i didn't use capifony but i never have this kind of error. I reuse the same file but i certainly miss something. Thanks in advance :)
My deploy file is like this :
# setup server
set :application, "Stackexchange Network"
set :domain, "37.187.66.229"
set :deploy_to, "/usr/share/nginx/www/stackexchange"
role :web, domain
role :app, domain
# git configuration
set :scm, :git
set :branch, "master"
set :repository, "file:///Applications/MAMP/htdocs/6.symfony_project/stackexchange"
set :deploy_via, :copy
ssh_options[:forward_agent] = true
# ssh log
set :user, "user"
set :password, "password"
set :use_sudo, false
set :keep_releases, 3
default_run_options[:pty] = true
# Symfony2 configuration
set :clear_controllers, true
set :controllers_to_clear, ['app_*.php']
set :model_manager, "doctrine"
set :use_orm, false
set :shared_files, ["app/config/parameters.yml"]
set :shared_children, ["app/logs", "app/cache"]
set :use_composer, true
set :update_vendors, true
set :dump_assetic_assets, true
set :writable_dirs, ["app/cache", "app/cache/prod", "app/cache/dev", "app/logs", "vendor"]
set :webserver_user, "www-data"
set :permission_method, :chown
set :use_set_permissions, true
before 'symfony:composer:update', 'symfony:copy_vendors'
after 'symfony:cache:warmup', 'deploy:cleanup'
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
# logger.level = Logger::INFO
# Be more verbose by uncommenting the following line
logger.level = Logger::MAX_LEVEL

You probably generated the Capfile for symfony 1.x.
Symfony2 Capfile should look something like the following (this is what capifony 2.3.0 generated for me):
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
require 'capifony_symfony2'
load 'app/config/deploy'
If you want to start from the beginning, try forcing Symfony version when capifying your project:
capifony -s 2 .

Related

Capifony error when rolling back

I have been using Capifony to deploy my application and everything works fine. However, when there's an error during the deploy, it rolls back and the rollback fails.
*** [deploy:update_code] rolling back
* executing "sudo -p 'sudo password: ' rm -rf /var/www/capifony/releases/20150923104657; true"
servers: ["myserver"]
[myserver] executing command
command finished in 110ms
**failed: "sh -c 'sudo -p '\\''sudo password: '\\'' sh -c '\\''cd /var/www/capifony/releases/20150923104657 && SYMFONY_ENV=prod /usr/local/bin/composer.phar install --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress'\\'''" on myserver**
Then the error on the browser is:
Compile Error: Symfony\Component\Debug\DebugClassLoader::loadClass(): Failed opening required '/mnt/app/www/capifony/releases/20150923104657/src/MyApp/CoreBundle/MyAppCoreBundle.php' (include_path='/mnt/app/www/capifony/shared/vendor/phpunit/phpunit-mock-objects:/mnt/app/www/capifony/shared/vendor/phpunit/php-file-iterator:/mnt/app/www/capifony/shared/vendor/phpunit/phpunit:/mnt/app/www/capifony/shared/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear')
From what I understand, it tries to do a composer install on the 20150923104657 release. However, this is the version it just deleted (rm -rf /var/www/capifony/releases/20150923104657). So it's normal that it fails. But I don't understand why it does that on this order.
Could anybody help me?
EDIT:
My Capfile:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
require 'capifony_symfony2'
My deploy.rb:
set :application, "myapp"
set :deploy_to, "/var/www/capifony"
set :app_path, "app"
set :repository, "https://git-myapp#github.com/Myapp/myapp.git"
set :scm, :git
set :branch, "master"
set :model_manager, "doctrine"
set :symfony_env_prod, "prod"
#recette
role :web, "myserver"
role :app, "myserver", :primary => true
set :use_sudo, true
set :user, "ubuntu"
set :keep_releases, 10
set :assets_install, true
set :dump_assetic_assets, true
set :use_composer, true
set :composer_bin, "/usr/local/bin/composer.phar"
set :update_vendors, false # false = install mode
set :clear_controllers, false
set :shared_files, ["app/config/parameters.yml"]
set :shared_children, [app_path + "/logs", app_path + "/Resources/images/myimages", web_path + "/media", web_path + "/zip", web_path + "/temp", "vendor"]
set :deploy_via, :remote_cache
set :writable_dirs, ["app/cache", "app/logs" , "app/../web", "app/Resources/images/myimages"]
set :webserver_user, "www-data"
set :permission_method, :chown
set :use_set_permissions, true
logger.level = Logger::MAX_LEVEL
before "deploy", "maintenance_enable", "cron_stop", "permissions_capifony", "finalize_update"
after "deploy", "deploy:cleanup", "others_tasks", "cron_start"
before "symfony:cache:warmup", "symfony:doctrine:schema:update"
I can also add the detail of the tasks if it is necessary.

Capistrano not really restarting a server?

I use Capistrano 2.15 and Nginx running on DigitalOcean droplet.
Sometimes, especially, when I install new gems or run migrations I need to hard reset my droplet to take my changes into effect.
This does not apply, if I simply change code somewhere, when running
cap deploy:restart
is fine.
Also, when I log in into my machine and run
service nginx restart
it does not help to capture new migrations.
deploy.rb
require "rvm/capistrano"
set :rvm_ruby_string, 'default'
set :rvm_type, :user
require "bundler/capistrano"
server "xx.xx.xx.xx", :web, :app, :db, primary: true
set :application, "xxx"
set :user, "deployer"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "git#bitbucket.org:xxx/#{application}.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
end
after "deploy:finalize_update", "deploy:symlink_config"
desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
before "deploy", "deploy:check_revision"
desc "tail production log files"
task :tail_logs, :roles => :app do
trap("INT") { puts 'Interupted'; exit 0; }
run "tail -f #{shared_path}/log/unicorn.log" do |channel, stream, data|
puts # for an extra line break before the host name
puts "#{channel[:host]}: #{data}"
break if stream == :err
end
end
end
namespace :assets do
task :symlink, roles: :web do
run ("rm -rf #{latest_release}/public/assets &&
mkdir -p #{latest_release}/public &&
mkdir -p #{shared_path}/assets &&
ln -s #{shared_path}/assets #{latest_release}/public/assets")
end
end
namespace :uploads do
desc <<-EOD
Creates the upload folders unless they exist
and sets the proper upload permissions.
EOD
task :setup, :except => { :no_release => true } do
dirs = [File.join(shared_path,'uploads' )]
run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
end
desc <<-EOD
[internal] Creates the symlink to uploads shared folder
for the most recently deployed version.
EOD
task :symlink, :except => { :no_release => true } do
run "rm -rf #{release_path}/public/uploads"
run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"
end
desc <<-EOD
[internal] Computes uploads directory paths
and registers them in Capistrano environment.
EOD
task :register_dirs do
set :uploads_dirs, %w(public/uploads)
set :shared_children, fetch(:shared_children) + fetch(:uploads_dirs)
end
after "deploy:finalize_update", "uploads:symlink"
on :start, "uploads:register_dirs"
end
Here is unicorn_init:
http://pastebin.com/cm6NCupK
when you deploy you use cap:deploy?
you use unicorn or passenger?
please paste your code here deploy.rb unicorn.rb(if you use unicorn) and unicorn_init.sh(or your sh file you create symlink from)
last question you use before_fork after_fork?(for zero downtime deploy?)

Capifony - task "symfony:cache:warmup" fails in prod environment without error message

I use capifony with symfony 2.
My deploy.rb
set :application, "Name project"
set :domain, "My Ip"
set :deploy_to, "My folder"
set :app_path, "app"
set :repository, "git#bitbucket.org:dou/test.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, or `none`
set :model_manager, "doctrine"
# Or: `propel`
set :shared_files, ["app/config/parameters.yml"]
set :shared_children, [app_path + "/logs", web_path + "/uploads", web_path + "/media", "vendor"]
set :use_composer, true
#set :composer_options, "--prefer-source --no-interaction"
set :deploy_via, :copy
set :branch, "master"
set :user, 'user'
set :password, 'pass'
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 :use_sudo, false
set :update_vendors, true
# Be more verbose by uncommenting the following line
logger.level = Logger::MAX_LEVEL
#set :dump_assetic_assets, true
set :ssh_options, { :forward_agent => true }
default_run_options[:pty] = true
And it was all ok. But yesterday I had an error.
* 2013-12-10 11:51:23 executing `symfony:cache:warmup'
--> Warming up cache
* executing "sh -c 'cd /home/myproject/beta/releases/20131210094811 && php app/console cache:warmup --env=prod --no-debug'"
servers: ["IP"]
[IP] executing command
** [out :: IP] Warming up the cache for the prod environment with debug false
command finished in 18712ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/myproject/beta/releases/20131210094811; true"
servers: ["IP"]
[IP] executing command
command finished in 633ms
failed: "sh -c 'sh -c '\\''cd /home/myproject/beta/releases/20131210094811 && php app/console cache:warmup --env=prod --no-debug'\\'''" on IP
Capifony try clear cache for prod, but it can't.So Can I see somehow error, why it can't clear cache? It clear cache for dev, but for prod it fails without any error for me.

Deploying Symfony2 with Capifony

i have problem with deploying symfony2 app to my server with capifony. I tried to pull with git directly to my server and that works.
here is my deploy.rb file
# 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"
and here is my error
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
I also tried to run this on my server directly through ssh and that works well.
Any idea? thnx
You don't seem to have set your SSH password. Either put the setting in your deploy.rb (not recommended) or let capifony ask you for it:
#set :password, "password" # the ssh password
set(:password){ Capistrano::CLI.password_prompt("Type your SSH password for user \"#{user}\": ") }
It's easier to find what's causing your deployment to fail if you increase the log verbosity level using the logger.level setting in your deploy.rb.
# IMPORTANT = 0
# INFO = 1
# DEBUG = 2
# TRACE = 3
# MAX_LEVEL = 3
logger.level = Logger::MAX_LEVEL
( documentation )

Capifony failed reinstalling vendors with Symfony2.1

I'm trying to deploy a Symfony2.1 project with Capifony2.1.14 and it failed when reinstalling vendors .
Configuration:
I'm on Mac OSX Montain Lion (client) and have a server on servergrove.com witch is on Ubuntu 12.04.1 LTS.
My deploy.rb file looks like this:
set :application, "DOA Manager Toshiba"
set :domain, "root#server.me"
set :deploy_to, "/var/www/vhosts/server.me"
set :app_path, "app"
set :user, "root"
set :use_sudo, false
set :repository, "git://github.com/****/****.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, or `none`
set :model_manager, "doctrine"
# Or: `propel`
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Symfony2 migrations will run
set :keep_releases, 3
set :update_vendors, true
ssh_options[:forward_agent] = true
# Be more verbose by uncommenting the following line
# logger.level = Logger::MAX_LEVEL
And here are the output on my terminal:
Can someone explain to me why I get this error and how I can fix it?
You should add:
set :use_composer, true
To your deploy.rb.

Resources