GithubHelp home page GithubHelp logo

symfony's Introduction

Capistrano: A deployment automation tool built on Ruby, Rake, and SSH.

Gem Version Build Status Code Climate CodersClan

Capistrano is a framework for building automated deployment scripts. Although Capistrano itself is written in Ruby, it can easily be used to deploy projects of any language or framework, be it Rails, Java, or PHP.

Once installed, Capistrano gives you a cap tool to perform your deployments from the comfort of your command line.

$ cd my-capistrano-enabled-project
$ cap production deploy

When you run cap, Capistrano dutifully connects to your server(s) via SSH and executes the steps necessary to deploy your project. You can define those steps yourself by writing Rake tasks, or by using pre-built task libraries provided by the Capistrano community.

Tasks are simple to make. Here's an example:

task :restart_sidekiq do
  on roles(:worker) do
    execute :service, "sidekiq restart"
  end
end
after "deploy:published", "restart_sidekiq"

Note: This documentation is for the current version of Capistrano (3.x). If you are looking for Capistrano 2.x documentation, you can find it in this archive.


Contents

Features

There are many ways to automate deployments, from simple rsync bash scripts to complex containerized toolchains. Capistrano sits somewhere in the middle: it automates what you already know how to do manually with SSH, but in a repeatable, scalable fashion. There is no magic here!

Here's what makes Capistrano great:

Strong conventions

Capistrano defines a standard deployment process that all Capistrano-enabled projects follow by default. You don't have to decide how to structure your scripts, where deployed files should be placed on the server, or how to perform common tasks: Capistrano has done this work for you.

Multiple stages

Define your deployment once, and then easily parameterize it for multiple stages (environments), e.g. qa, staging, and production. No copy-and-paste necessary: you only need to specify what is different for each stage, like IP addresses.

Parallel execution

Deploying to a fleet of app servers? Capistrano can run each deployment task concurrently across those servers and uses connection pooling for speed.

Server roles

Your application may need many different types of servers: a database server, an app server, two web servers, and a job queue work server, for example. Capistrano lets you tag each server with one or more roles, so you can control what tasks are executed where.

Community driven

Capistrano is easily extensible using the rubygems package manager. Deploying a Rails app? Wordpress? Laravel? Chances are, someone has already written Capistrano tasks for your framework of choice and has distributed it as a gem. Many Ruby projects also come with Capistrano tasks built-in.

It's just SSH

Everything in Capistrano comes down to running SSH commands on remote servers. On the one hand, that makes Capistrano simple. On the other hand, if you aren't comfortable SSH-ing into a Linux box and doing stuff on the command-line, then Capistrano is probably not for you.

Gotchas

While Capistrano ships with a strong set of conventions that are common for all types of deployments, it needs help understanding the specifics of your project, and there are some things Capistrano is not suited to do.

Project specifics

Out of the box, Capistrano can deploy your code to server(s), but it does not know how to execute your code. Does foreman need to be run? Does Apache need to be restarted? You'll need to tell Capistrano how to do this part by writing these deployment steps yourself, or by finding a gem in the Capistrano community that does it for you.

Key-based SSH

Capistrano depends on connecting to your server(s) with SSH using key-based (i.e. password-less) authentication. You'll need this working before you can use Capistrano.

Provisioning

Likewise, your server(s) will likely need supporting software installed before you can perform a deployment. Capistrano itself has no requirements other than SSH, but your application probably needs database software, a web server like Apache or Nginx, and a language runtime like Java, Ruby, or PHP. These server provisioning steps are not done by Capistrano.

sudo, etc.

Capistrano is designed to deploy using a single, non-privileged SSH user, using a non-interactive SSH session. If your deployment requires sudo, interactive prompts, authenticating as one user but running commands as another, you can probably accomplish this with Capistrano, but it may be difficult. Your automated deployments will be much smoother if you can avoid such requirements.

Shells

Capistrano 3 expects a POSIX shell like Bash or Sh. Shells like tcsh, csh, and such may work, but probably will not.

Quick start

Requirements

  • Ruby version 2.0 or higher on your local machine (MRI or Rubinius)
  • A project that uses source control (Git, Mercurial, and Subversion support is built-in)
  • The SCM binaries (e.g. git, hg) needed to check out your project must be installed on the server(s) you are deploying to
  • Bundler, along with a Gemfile for your project, are recommended

Install the Capistrano gem

Add Capistrano to your project's Gemfile using require: false:

group :development do
  gem "capistrano", "~> 3.17", require: false
end

Then run Bundler to ensure Capistrano is downloaded and installed:

$ bundle install

"Capify" your project

Make sure your project doesn't already have a "Capfile" or "capfile" present. Then run:

$ bundle exec cap install

This creates all the necessary configuration files and directory structure for a Capistrano-enabled project with two stages, staging and production:

├── Capfile
├── config
│   ├── deploy
│   │   ├── production.rb
│   │   └── staging.rb
│   └── deploy.rb
└── lib
    └── capistrano
            └── tasks

To customize the stages that are created, use:

$ bundle exec cap install STAGES=local,sandbox,qa,production

Note that the files that Capistrano creates are simply templates to get you started. Make sure to edit the deploy.rb and stage files so that they contain values appropriate for your project and your target servers.

Command-line usage

# list all available tasks
$ bundle exec cap -T

# deploy to the staging environment
$ bundle exec cap staging deploy

# deploy to the production environment
$ bundle exec cap production deploy

# simulate deploying to the production environment
# does not actually do anything
$ bundle exec cap production deploy --dry-run

# list task dependencies
$ bundle exec cap production deploy --prereqs

# trace through task invocations
$ bundle exec cap production deploy --trace

# lists all config variable before deployment tasks
$ bundle exec cap production deploy --print-config-variables

Finding help and documentation

Capistrano is a large project encompassing multiple GitHub repositories and a community of plugins, and it can be overwhelming when you are just getting started. Here are resources that can help:

Related GitHub repositories:

  • capistrano/sshkit provides the SSH behavior that underlies Capistrano (when you use execute in a Capistrano task, you are using SSHKit)
  • capistrano/rails is a very popular gem that adds Ruby on Rails deployment tasks
  • mattbrictson/airbrussh provides Capistrano's default log formatting

GitHub issues are for bug reports and feature requests. Please refer to the CONTRIBUTING document for guidelines on submitting GitHub issues.

If you think you may have discovered a security vulnerability in Capistrano, do not open a GitHub issue. Instead, please send a report to [email protected].

How to contribute

Contributions to Capistrano, in the form of code, documentation or idea, are gladly accepted. Read the DEVELOPMENT document to learn how to hack on Capistrano's code, run the tests, and contribute your first pull request.

License

MIT License (MIT)

Copyright (c) 2012-2020 Tom Clements, Lee Hambley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

symfony's People

Contributors

alafon avatar aradoje avatar fdonzello avatar issei-m avatar kriswallsmith avatar nyholm avatar pborreli avatar peterjmit avatar romancieslik avatar romaricdrigon avatar rubencm avatar ruudk avatar sagikazarmark avatar sgrodzicki avatar tomcant avatar torjusb avatar will-in-wi avatar xavismeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony's Issues

How to run doctrine:migrations:migrate on demand

Current setup following readme:

namespace :tasks do
  task :migrate do
    invoke 'symfony:console', 'doctrine:migrations:migrate'
  end
end

namespace :deploy do
  after :starting, 'composer:install_executable'
  after :updated, 'tasks:migrate'
end

I don't always have migrations. I tried removing the '--no-interaction flag but the interaction never runs if no migrations are present. My cap aborts:

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ...@...: php exit status: 4
php stdout: Application Migrations                    


Migrating up to 0 from 0
php stderr: [Doctrine\DBAL\Migrations\MigrationException]  
  Could not find any migrations to execute.      



doctrine:migrations:migrate [--write-sql] [--dry-run] [--query-time] [--configuration[="..."]] [--db-configuration[="..."]] [--em[="..."]] [version]

SSHKit::Command::Failed: php exit status: 4
php stdout: Application Migrations                    


Migrating up to 0 from 0
php stderr: [Doctrine\DBAL\Migrations\MigrationException]  
  Could not find any migrations to execute.

Is there any way to run the task on demand like with Capifony those days?
http://capifony.org/#useful-tasks

Possibly related to #28 by @jurgenweber

My parameters.yml file gets overriden

I upload a "production" app/config/parameters.yml, but then "composer install" is invoked so it overrides that custom parameters.yml and post-install scripts from Symfony's composer fail since it can't connect to database.

How can I handle this?

build_bootstrap should execute php binary

build_bootstrap task should execute php binary, not the script itself.

DEBUG [bc4bfe9c]        /usr/bin/env: ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
DEBUG [05f38581]        /usr/bin/env: ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
cap aborted!
./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php stdout: Nothing written
./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php stderr: Nothing written
cd /var/www/foobar/releases/20140309213947 && ( SYMFONY_ENV=prod /usr/bin/env ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionB
undle/Resources/bin/build_bootstrap.php )
/usr/bin/env: ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php: Permission denied

bug after 0.4.0 version undefined local variable or method `symfony_cache_path'

00:00 deploy:symlink:linked_dirs
01 mkdir -p /var/www/test/myproject/releases/20160610144818/app
** Invoke symfony:create_cache_dir (first_time)
** Execute symfony:create_cache_dir
cap aborted!
NameError: undefined local variable or method symfony_cache_path' for #<SSHKit::Backend::Printer:0x007fb6b29277a8> /Library/Ruby/Gems/2.0.0/gems/capistrano-symfony-1.0.0.rc2/lib/capistrano/tasks/symfony.rake:52:inblock (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.10.0/lib/sshkit/backends/abstract.rb:80:in within' /Library/Ruby/Gems/2.0.0/gems/capistrano-symfony-1.0.0.rc2/lib/capistrano/tasks/symfony.rake:51:inblock (3 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.10.0/lib/sshkit/backends/abstract.rb:29:in instance_exec' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.10.0/lib/sshkit/backends/abstract.rb:29:inrun'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.10.0/lib/sshkit/runners/parallel.rb:12:in block (2 levels) in execute' Tasks: TOP => symfony:create_cache_dir The deploy has failed with an error: undefined local variable or methodsymfony_cache_path' for #SSHKit::Backend::Printer:0x007fb6b29277a8
** Invoke deploy:failed (first_time)
** Execute deploy:failed

I don't know what is missing ... i use capistrano 3.5

SYMFONY_ENV not set correctly

In defaults.rb this code is called:

fetch(:default_env).merge!(symfony_env: fetch(:symfony_env))

Problem is that this code is usually executed before the stage-specific configuration. So if I have a 'staging.rb' stage with a config like this:

set :symfony_env, 'staging'

Capistrano will still call command like:

SYMFONY_ENV=prod /usr/bin/env some-command....

installation could not find gem

Hi,

I tried the installation but it does not seem to work and there are no workarounds on the web for the problem. Here is what I did:

Added capistrano/symfony in my Gemfile

group :development do
  gem "capistrano", "~> 3.4"
  gem 'capistrano-symfony', '~> 1.0.0.rc1'
end

Launched cap install

$ bundle exec cap install
Could not find gem 'capistrano-symfony (~> 1.0.0.rc1)' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.

As mentionned in the error, I launched bundle install:

$ bundle install
Your Gemfile has no gem server sources. If you need gems that are not already on your machine, add a line like this to your Gemfile:
source 'https://rubygems.org'
Could not find gem 'capistrano-symfony (~> 1.0.0.rc1)' in any of the gem sources listed in your Gemfile or available on this machine.

This was done on a fresh ubuntu install. Ruby 2 was installed with rvm and ruby -v returned:

$ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]

Capistrano dependency error

Hello,
I change my message I made mistake, I never use bundle before,
I create a new Gemfile, and install Capistrano and capistrano/symfony.
So, it's not an issue, but perhaps more details in readme for symfony dev with only beginners skills on ruby, like me :)
Thanks

Symfony Flex?

Symfony Flex come with a different structure logic and then some tasks and vars are not needed anymore:

  • symfony:create_cache_dir => The cache directory is automatically created on cache:warmup comand
  • symfony:clear_controllers => The only controller is now index.php for all envs.
  • :app_path => There is no app path anymore
  • :app_config_path => Well, now it's config, not app/config. And what is the usage of this var?
  • :sensio_distribution_version => Sensio distribution is not needed anymore for Flex structure.

Regarding this analyse, nothing seems to be needed except the symfony_console which we may put some default flag like --no-interaction. BTW, the --no-debug flag is not useful as the debug is determined by the choosen env from .env file IMO.

But we have to keep BC with the old structure.

What would you suggest? Maybe simply create a capistrano-symfony-console for flex user and import it on this plugin? Maybe create a plugin just for a console command with default flag is also overkill, I don't know yet.

Rename options "linked_*"

For compatibility with capifony and because at least I find shared_* more obvious the both options linked_dirs and linked_files should get their old names (shared_dirs [1] and shared_files) back. It isn't really important, that they are really "linked" somehow (because theoretically they could be copied), but interesting is, that that are files and folders, that are shared between deployments.

[1] I must admit, that the old name shared_children is a little bit confusing. personally I'd prefer shared_folders anyway.

Create/update parameters.yml

Right now it's just a loose idea, but it would be nice, if this gem could ensure, that the parameters.yml exists and is properly set up (via template probably) before deploy:check:linked_files, because thats the task, which fails, if the file doesn't exists. It should also be possible to use some values from a remote file. I don't know, if there are already some best practices though.

parameters.yml not symlinked on FreeBSD

I just updated a symfony app that used capifony with capistrano 2.

I use all the default values without adding parameters.yml to the :linked_files.

For some reason the symlink is not created. The app will deploy and use the non-shared file under app/config/parameters.yml.

The command is executed:
Running /usr/bin/env [ -f /usr/local/www/apache24/noexec/foobar/shared/app/config/parameters.yml ] as [email protected]
DEBUG [95af9b97] Command: [ -f /usr/local/www/apache24/noexec/foobar/shared/app/config/parameters.yml ]

The following message is used by Symfony itself, not Capistrano, I think:
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
DEBUG [a9e4aa32] Creating the "app/config/parameters.yml" file

When I add :linked_files as mentioned in #11 (comment):

set :linked_files, [fetch(:app_path) + '/config/parameters.yml']

I get:

Incenteev\ParameterHandler\ScriptHandler::buildParameters
Script Incenteev\ParameterHandler\ScriptHandler::buildParameters handling the post-install-cmd event terminated with an exception

  file_put_contents(app/config/parameters.yml): failed to open stream: Permission denied

Are there any sepcial privileges to allow symlinking? Does the :webserver_user require sudo?

Never had problems with the default configuration on Debian. Maybe this is a FreeBSD issue. For instance there is no www-data User or group on this server. The group is vuser.

I've encountered many problems with Capistrano with FreeBSD. Problems with setfacl (#40), default bash (#24) and others. Maybe there is a problem with symlinks in general too:
http://www.freebsddiary.org/ln.php

Tag version 0.2

The last commit is from mid may and there is no serious issue open (as far as I can see), therefore a second release 0.2 is useful.

Overriding app_path and web_path defaults doesn't seem to take effect

My Symfony2 project root is in a sub-directory (i.e. the structure is '/htdocs/app, /htdocs/bin' etc). I do this to avoid mixing my Vagrant files in with Symfony files. I overrode the app_path and web_path defaults in deploy.rb using:

set :app_path, 'htdocs/app'
set :web_path, 'htdocs/web'

but when I run 'cap staging deploy' the defaults of 'app' and 'web are still in effect. I'm not a Ruby developer so debugging where this is falling down is beyond me I'm afraid! Thanks in advance for any help given.

A test suite is needed

capistrano/capistrano has a rspec and cucumber test suite, we should be looking were possible to leverage and provide the same coverage for this library.

Unable to override :controllers_to_clear

I've some specific app_xxx.php files I do want to deploy. I've modified my production.rb so that it overrides the custom value:

set :controllers_to_clear, ["app_dev.php", "app_test.php"]

However, changes are not reflected when doing cap production deploy and it still removes all the app_*.php files. Am I missing something?

Unable to set SYMFONY_ENV on FreeBSD

$ bundle exec cap production deploy
INFO[6a80bc06] Running /usr/bin/env mkdir -p /tmp/app/ on host.com
DEBUG[6a80bc06] Command: ( SYMFONY_ENV=prod /usr/bin/env mkdir -p /tmp/app/ )
DEBUG[6a80bc06]     SYMFONY_ENV=prod: Command not found.

In FreeBSD the command should look like this:

setenv SYMFONY_ENV prod

Allow symlinks for assets

It should be possible to pass --symlink or --symlink --relative to assets:install.

Like in

set :symfony_assets, :copy # :symlink :relative

Seems that some tasks dit not run

When i try adeploy it seems that some tasks from
https://github.com/capistrano/symfony/blob/master/lib/capistrano/tasks/symfony.rake

did not run propperly..
1.) no bootstrap is created
2.) the permissions were not set

set :file_permissions_paths,         [fetch(:app_path),fetch(:log_path), fetch(:cache_path)]
set :webserver_user,        "www-data"
set :permission_method,     :acl
set :use_set_permissions,   true

if i put this in my deploy.rb file

#if i use this one with a custom invoke it works..
set :file_permissions_users, ["www-data"]
before "deploy:updated", "deploy:set_permissions:acl"
#copied task to my rb file
before "symfony:cache:warmup", "deploy:build_bootstrap"

i also couldnt find were you use this var

set :webserver_user,        "www-data"

my whole deploy.rb looks like this

#config valid only for Capistrano 3.1
lock '3.1.0'
#General Settings
set :application, 'SymfonyProject'
set :repo_url, 'git@XXXX/xxx.git'
set :scm,         :git
set :keep_releases,  3
set :use_sudo,     false
#Symfony Settings
#Symfony environment
set :symfony_env,  "prod"
#Symfony application path
set :app_path,              "app"
#Symfony web path
set :web_path,              "web"
#Symfony log path
set :log_path,              fetch(:app_path) + "/logs"
#Symfony cache path
set :cache_path,            fetch(:app_path) + "/cache"
#Symfony config file path
set :app_config_path,       fetch(:app_path) + "/config"
#Controllers to clear
set :controllers_to_clear, ["app_*.php"]
#Files that need to remain the same between deploys
set :linked_files,          []
#Dirs that need to remain the same between deploys (shared dirs)
set :linked_dirs,           [fetch(:log_path), fetch(:web_path) + "/uploads"]
#Dirs that need to be writable by the HTTP Server (i.e. cache, log dirs)
set :file_permissions_paths,         [fetch(:app_path),fetch(:log_path), fetch(:cache_path)]
set :file_permissions_users, ["www-data"]
#Name used by the Web Server (i.e. www-data for Apache)
#set :webserver_user,    "www-data"
#Method used to set permissions (:chmod, :acl, or :chown)
#set :permission_method,     false
#Execute set permissions
#set :use_set_permissions,   false
before "deploy:updated", "deploy:set_permissions:acl"
before "symfony:cache:warmup", "deploy:build_bootstrap"
#Composer
set :composer_install_flags, "--no-dev --no-scripts --verbose --prefer-dist --optimize-autoloader --no-progress"
set :symfony_console_path, fetch(:app_path) + "/console"
set :symfony_console_flags, "--no-debug"
#Assets install
set :assets_install_path,   fetch(:web_path)
SSHKit.config.command_map[:composer] = "php composer.phar"
#the copied task from your file(deploy:build_bootstrap)

something wrong with this config ?

Cache permissions issue

Hi! I am working on setting up Capistrano for a Symfony project and I've run into a strange permissions issue and I hope someone can point me in the right direction...

The deployments are successful, however, when I attempt to access the page, the web server logs are showing me a permissions error:

[Thu Jun 18 12:49:14.785114 2015] [:error] [pid 19090] [client 172.20.0.171:35065] PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Failed to write cache file "/var/www/cdpaccess/releases/20150618174628/app/cache/cdp/prod/classes.php".' in /var/www/cdpaccess/shared/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php:205\nStack trace:\n#0 /var/www/cdpaccess/shared/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php(122): Symfony\\Component\\ClassLoader\\ClassCollectionLoader::writeCacheFile('/var/www/cdpacc...', '<?php  ????name...')\n#1 /var/www/cdpaccess/releases/20150618174628/app/bootstrap.php.cache(758): Symfony\\Component\\ClassLoader\\ClassCollectionLoader::load(Array, '/var/www/cdpacc...', 'classes', false, false, '.php')\n#2 /var/www/cdpaccess/releases/20150618174628/web/app.php(20): Symfony\\Component\\HttpKernel\\Kernel->loadClassCache()\n#3 {main}\n  thrown in /var/www/cdpaccess/shared/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php on line 205

Here is some information that should help:

Here is a gist of the deployment

Gems:

*** LOCAL GEMS ***

bundler (1.10.4)
capistrano (3.4.0)
capistrano-composer (0.0.6)
capistrano-file-permissions (0.1.1)
capistrano-symfony (0.4.0)
colorize (0.7.7)
i18n (0.7.0)
net-scp (1.2.1)
net-ssh (2.9.2)
rake (10.4.2)
sshkit (1.7.1)

deploy.rb:

lock '3.4.0'

set :application, 'cdpaccess'
set :repo_url, '[email protected]:InternationalCodeCouncil/cdpaccess.git'
set :deploy_to, '/var/www/html/cdpaccess'

# Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('app/config/parameters.yml', 'src/Caxy/AvectraBundle/Resources/config/parameters.yml')

# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('vendor')

# Install composer
SSHKit.config.command_map[:composer] = "php #{shared_path.join("composer.phar")}"
set :composer_install_flags, '--no-interaction --optimize-autoloader'
after 'deploy:starting', 'composer:install_executable'

# Dump js routes
before 'deploy:updated', 'deploy:dump_js_routes'

# Set Symfony permissions
set :webserver_user, "apache"
set :permission_method, :acl
set :use_set_permissions, true
set :file_permissions_paths, [fetch(:log_path), fetch(:cache_path), "app/var", "web/uploads"]

# Install assets
before 'deploy:updated', 'symfony:assets:install'
before 'deploy:updated', 'symfony:assetic:dump'

namespace :deploy do
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

  task :dump_js_routes do
    invoke 'symfony:console', 'bazinga:expose-translation:dump', 'web/translations'
  end
end

All of the tasks seem to be running. I logged into the server and checked permissions on the offending folders - it looks like the setfacl command was executed:

[cdpaccess@cdp-qa app]$ ls -l
total 120
-rw-rw-r--  1 cdpaccess cdpaccess   141 Jun 18 12:40 AppCache.php
-rwxrwxr-x  1 cdpaccess cdpaccess  6716 Jun 18 12:40 AppKernel.php
-rw-rw-r--  1 cdpaccess cdpaccess   487 Jun 18 12:40 Application.php
-rw-rw-r--  1 cdpaccess cdpaccess   474 Jun 18 12:40 autoload.php
-rw-rw-r--  1 cdpaccess cdpaccess 48879 Jun 18 12:54 bootstrap.php.cache
drwxrwxr-x+ 3 cdpaccess cdpaccess    16 Jun 18 12:54 cache
-rw-rw-r--  1 cdpaccess cdpaccess  1643 Jun 18 12:54 check.php
drwxrwxr-x  4 cdpaccess cdpaccess  4096 Jun 18 12:54 config
-rwxrwxr-x  1 cdpaccess cdpaccess   918 Jun 18 12:40 console
drwxrwxr-x  4 cdpaccess cdpaccess    30 Jun 18 12:40 DoctrineMigrations
lrwxrwxrwx  1 cdpaccess cdpaccess    34 Jun 18 12:54 logs -> /var/www/cdpaccess/shared/app/logs
drwxrwxr-x  2 cdpaccess cdpaccess    29 Jun 18 12:40 PHPUnit
-rw-rw-r--  1 cdpaccess cdpaccess  2234 Jun 18 12:40 phpunit.xml.dist
drwxrwxr-x  7 cdpaccess cdpaccess    77 Jun 18 12:40 Resources
-rw-rw-r--  1 cdpaccess cdpaccess 26577 Jun 18 12:54 SymfonyRequirements.php
drwxrwxr-x+ 3 cdpaccess cdpaccess    31 Jun 18 12:54 var

If I run the setfacl commands 1 last time after the deployment has been complete, it works and I can access the site.

I've used capistrano successfully on other Symfony projects (although I have had issues with permissions), but I'm kind of stuck here. Any advice, workarounds, etc would be appreciated. I'm not a ruby developer so bear with me!

Thanks in advance.

setfacl error once webserver has written files to directories

capistrano/symfony has been working great to deploy my code. It's only now, once people have started uploading files to the website, that a problem has appeared.

This is using capistrano-symfony (1.0.0.rc1)

Files are deployed as myuser and PHP runs as www-data. At the end of a deployment, I now get the following error:

INFO [bdb5172c] Running /usr/bin/env setfacl -Rn -m u:www-data:rwX -m u:myuser:rwX /var/www/mysite.com/shared/var /var/www/mysite.com/shared/web/uploads as [email protected]
DEBUG [bdb5172c] Command: ( export SYMFONY_ENV="prod" ; /usr/bin/env setfacl -Rn -m u:www-data:rwX -m u:myuser:rwX /var/www/mysite.com/shared/var /var/www/mysite.com/shared/web/uploads )
DEBUG [bdb5172c]        setfacl: /var/www/mysite.com/shared/web/uploads/temp/56dd9248c5ac4.jpg: Operation not permitted
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: Exception while executing as [email protected]: setfacl exit status: 1
setfacl stdout: Nothing written
setfacl stderr: setfacl: /var/www/mysite.com/shared/web/uploads/temp/56dd9248c5ac4.jpg: Operation not permitted

SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: setfacl exit status: 1
setfacl stdout: Nothing written
setfacl stderr: setfacl: /var/www/mysite.com/shared/web/uploads/temp/56dd9248c5ac4.jpg: Operation not permitted

SSHKit::Command::Failed: setfacl exit status: 1
setfacl stdout: Nothing written
setfacl stderr: setfacl: /var/www/mysite.com/shared/web/uploads/temp/56dd9248c5ac4.jpg: Operation not permitted

Tasks: TOP => symfony:set_permissions
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as [email protected]: Exception while executing as [email protected]: setfacl exit status: 1
setfacl stdout: Nothing written
setfacl stderr: setfacl: /var/www/mysite.com/shared/web/uploads/temp/56dd9248c5ac4.jpg: Operation not permitted

All folders are owned as myuser, and files in uploads/temp are owned by www-data. In my deploy.rb I have:

set :permission_method, :acl
set :file_permissions_users, ["www-data"]
set :file_permissions_paths, ["var", "web/uploads"]

set :linked_files, ["app/config/parameters.yml"]
set :linked_dirs, ["var", "web/uploads"]

getfacl on the uploads directory and the uploads/temp directory gives:

$ getfacl uploads
# file: .
# owner: myuser
# group: myuser
user::rwx
user:www-data:rwx
user:myuser:rwx
group::rwx
mask::rwx
other::r-x
default:user::rwx
default:user:www-data:rwx
default:user:myuser:rwx
default:group::rwx
default:mask::rwx
default:other::r-x

And on one of the uploaded images:

$ getfacl 56dd83459edf0_thumb.jpg
# file: 56dd83459edf0_thumb.jpg
# owner: www-data
# group: www-data
user::rw-
user:www-data:rwx               #effective:rw-
user:myuser:rwx                 #effective:rw-
group::rwx                      #effective:rw-
mask::rw-
other::r--

What have I misunderstood and misconfigured?

Delay execution of deploy:set_permissions:*

Currently, deploy:set_permissions:* is executed in deploy:updating, before deploy:updated where symfony:cache:warmup is run.

I have a situation where the deployment user is not root and is different from the webserver user. In this case the app/cache directory is marked as 777 but the generated cache files are not. Sometimes symfony will create more cache files when the application is run, in this case it will not be able to write to the cache directory.

So this can be solved if the deploy:set_permissions:* is moved after symfony:cache:warmup.

how to run a console command?

I found in your readme...

namespace :deploy do
  task :migrate do
    invoke 'symfony:console', 'doctrine:migrations:migrate', '--no-interaction', 'db'
  end
end

but

SSHKit::Runner::ExecuteError: Exception while executing on host vagrant-front01.local: Don't know how to build task 'symfony:console'

I think found in issue 10, to use symfony:command but

SSHKit::Runner::ExecuteError: Exception while executing on host vagrant-front01.local: Don't know how to build task 'symfony:command'

my code:

task :before_symlink do
  on roles(:front) do |host|
    #generate browser detection cache file
    invoke 'symfony:command', 'browscap:update'

    #dump assets (if using assetic)"
    invoke 'symfony:command', 'assetic:dump'

    #set queue attributes
    invoke 'symfony:command', 'app:queue:sqs:set-attributes'

    #translations
    invoke 'symfony:command', 'app:translation:sync'
  end
end

namespace :deploy do
  before :starting, 'composer:install_executable'

  before :publishing, 'before_symlink'

  after :finishing, "deploy:cleanup"
end

how can I run a console command? :0

Versions:
gem list | grep capistrano
capistrano (3.2.1, 2.15.5)
capistrano-composer (0.0.4)
capistrano-file-permissions (0.1.0)
capistrano-symfony (0.3.0)

I did just find this thuo:
https://github.com/capistrano/symfony/blob/master/lib/capistrano/tasks/symfony.rake#L21

ok, i'll go back to symfony:console.

Duplicate executions

Some tasks do stuff, that is already (usually) covered by composer scripthandlers and shouldn't run by default.

See also: https://github.com/symfony/symfony-standard/blob/master/composer.json

  • cache warm up

    {
        "scripts": {
            "post-install-cmd": [
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
            ],
            "post-update-cmd": [
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
            ]
        },
        "extra": {
            "symfony-cache-warmup": "true"
        }
    }
    

    in composer.json

  • built-bootstrap

    {
        "scripts": {
            "post-install-cmd": [
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
            ],
            "post-update-cmd": [
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
            ]
        }
    }
    
  • install assets

    {
        "scripts": {
            "post-install-cmd": [
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
            ],
            "post-update-cmd": [
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
            ]
        }
    }
    

I am not entirely sure, if it's useful to drop them at completely (they are not too complicated to write in ones Capfile, or deploy.rb themself), but at least it should be possible to avoid them.

Update: After I played around with different scenarios, I must admit, that it looks more useful to remove the corresponding script handlers from the dependency resolver (composer), but let the deployment tool (capistrano) do the job

Override app_path/web_path

In our project Symfony is in the separate directory. I'm trying in my deploy.rb to do
set :app_path, "symfony/app"
without success. Is there any way to take care of it?

'execute' should be wrapped in an 'on' scope

I'm trying to deploy a SF3 app with

  • capistrano-3.6.1
  • capistrano-symfony-1.0.0.rc2

I got an error :

** Invoke symfony:schema_update (first_time)
** Execute symfony:schema_update
Warning: 'execute' should be wrapped in an 'on' scope in /usr/local/bundle/gems/capistrano-symfony-1.0.0.rc2/lib/capistrano/dsl/symfony.rb:52.

  task :example do
    on roles(:app) do
      execute 'whoami'
    end
  end

cap aborted!

I think someone just has to add a "on roles" there, but as i'm using it on a gitlab docker runner, i can't easily edit the file and test it...

Permission issue using ACL

Hi there,

I use ACL to set permissions on certain directories upon deployment. Here's the part of deploy.rb:

set :linked_files, ['app/config/parameters.yml']
set :linked_dirs, ["app/logs", "web/uploads"]

set :permission_method, :acl
set :file_permissions_paths, ["app/logs", "app/cache", "web/uploads"]
set :file_permissions_users, ["www-data"]

before "deploy:updated", "deploy:set_permissions:acl"

So this works on the first deployment, when you set up your directories where nothing has been created inside them yet. However, after some time, say you uploaded an image to the web/uploads directory, the file would be under the www-data user, while the directory is still owned by the deploy user. So when you deploy code again, capistrano will fail because it attempts to run acl on a directory that contains files owned by www-data.

How can I work around this?

Exporting of SYMFONY_ENV

It seems that capistrano/symfony do not export the SYMFONY_ENV variable. Given this post-install-cmd scripts do not run in the chosen environment. I set this in my deploy script and now everything work well.

   set :default_env, {
     'SYMFONY_ENV' => 'prod'
   }

Cannot deploy: symfony_cache_path undefined

I was trying to use capistrano symfony, therefore I followed your docs here on github but when I try to deploy, I receive the following error:

"NameError: undefined local variable or method 'symfony_cache_path' for #SSHKIT:Backend::Printer:0x2f8b360.

This error occurs within symfony.rake, when trying to run the task "symfony:create_cache_dir".
I inspected the file "symfony.rake" and could not find from where the variable "symfony_cache_path" should be filled.

Did I miss something? I think, that I did not understand well on how to use a git repository within capistrano symfony.

I am developing on a dev machine lets say with ip .67, and the code is being versionised on another virtual machine with ip .68 by using Git and Bitbucket. In deploy.rb, I tried to connect to the git repo. In development, I am using an ssh key to push changes to the bitbucket - so I thought when using the same user from the dev machine in the deploy.rb file, I should also be able to connec to git repo:

set :repo_url, 'ssh://[email protected]:7999/nav/myrepo.git'
set :ssh_user, 'jenkins'
server 'http://xxx.xxx.xx.68', user: fetch(:ssh_user), roles: %w{web app db}

When running this, I get the error described above..

Make bootstrap cache configurable

Hi, it's me again. I've seen a TODO

task :build_bootstrap do
  on release_roles :all do
    within release_path do
      # TODO: does this need to be configurable?
      execute :php, "./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php", fetch(:app_path)
    end
  end
end

I'd say yes. Actually only because I consider dropping the bootstrap-cache entirely, because

  • It is the only "part" of the DistributionBundle I use, so I'd like to drop that bundle
  • It looses it's benefit, when there is a proper bytecode cache with constant stat-calls

Right now I cannot drop the bundle, because it would break the deployment (as far as I've seen I cannot remove tasks from the flow, right?)

parameters.yml updates

It would be nice to have a built in task to sync parameters.yml with the dist version.

I have created a couple of simple tasks which provide this functionality: https://gist.github.com/carlcraig/377ed30bfa2015ea5049

Im not sure if they are worth integrating into this module (and I wouldn't know where to start with integrating them).

Hopefully they are useful.

Symfony 3

Could we have the same version for Symfony 3 ?

What is the syntax to call a symfony command ?

The README mention this:

namespace :deploy do
  task :migrate do
    symfony_console('doctrine:migrations:migrate', '--no-interaction')
  end
end

But when I use symfony_console in my own task I get this error:

** Invoke paris (first_time)
** Execute paris
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy:set_symfony_env (first_time)
** Execute deploy:set_symfony_env
** Invoke opcache:clear (first_time)
** Execute opcache:clear
cap aborted!
NoMethodError: undefined method `execute' for main:Object
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-symfony-1.0.0.rc2/lib/capistrano/dsl/symfony.rb:52:in `symfony_console'
app/config/deploy.rb:53:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
/usr/local/lib/ruby/gems/2.2.0/gems/airbrussh-1.0.1/lib/airbrussh/rake/context.rb:55:in `execute'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/application.rb:14:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/bin/cap:3:in `<top (required)>'
/usr/local/bin/cap:23:in `load'
/usr/local/bin/cap:23:in `<main>'
Tasks: TOP => opcache:clear

I'm using capistrano-symfony rc2 and capistrano 3.5.0. The CHANGELOG mention a change about symfony_console but I'm not sure to understand it.

Thanks for your help,

How to use this?

Should I be using cap install or is there another command line tool? I don't see symfony anywhere in my path

OS is OS X

When I do run cap install, it creates the various files but not in the app folder, is this normal behaviour?

Also this is the Capfile it created (with my manual addition of symfony)

# Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

# Include tasks from other gems included in your Gemfile
require 'capistrano/symfony'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

Is this correct?

Copy vendor map before composer install

If you link the vendor folder and your build fails and you go back, you will be hanging with wrong versions of your packages.

So a different solution would be copying the vendor map to the new release to speed up composer install.

Any thoughts on this?

Doctrine migrations task freezes deploy

My migration command:

SYMFONY_ENV=prod /usr/bin/env php app/console doctrine:migrations:migrate --verbose --no-debug

The task:

namespace :tasks do
  task :migrate do
    invoke 'symfony:console', 'doctrine:migrations:migrate', '--verbose'
  end
end

namespace :deploy do
  after :updated, 'tasks:migrate'
end

The interaction starts and asks me if I want to migrate. Wheter I choose Y or N the cap deploy will freeze.
This normally indicates there is an error inside the migrations files.

I logged in to the server with the same SSH user and run the command manually with success.
In my case all migrations already were migrated:

WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y
No migrations to execute.

I know there are some issues with Capistrano and @freebsd. For instance I had to change the default bash to be able to export the SYMFONY_ENV:
#24 (comment)

Any idea why the process is freezing? I run the cap deploy with --trace and the migrations with --verbose but no feedback.

Nothing inside the error logs. After cancelling:

^Ccap aborted!
Interrupt: 
/var/lib/gems/1.9.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:20:in `join'
/var/lib/gems/1.9.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:20:in `map'
/var/lib/gems/1.9.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:20:in `execute'
/var/lib/gems/1.9.1/gems/sshkit-1.7.1/lib/sshkit/coordinator.rb:15:in `each'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:55:in `on'
/var/lib/gems/1.9.1/gems/capistrano-symfony-0.4.0/lib/capistrano/tasks/symfony.rake:12:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:16:in `invoke'
app/config/deploy.rb:60:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/dsl/task_enhancements.rb:14:in `block in after'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:16:in `invoke'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/tasks/framework.rake:65:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/tasks/framework.rake:61:in `each'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/tasks/framework.rake:61:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
/var/lib/gems/1.9.1/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
/usr/local/bin/cap:23:in `load'
/usr/local/bin/cap:23:in `<main>'
Tasks: TOP => symfony:console
The deploy has failed with an error: 
** Invoke deploy:failed (first_time)
** Execute deploy:failed

Capfile: cannot load such file -- capistrano/symfony

Trying to use this deployer for the first time, a bit unsure if I've done something incorrect or if the docs are out of date

neil@neil-ubuntu:~/development/blah$ cap -v
Capistrano Version: 3.4.0 (Rake Version: 10.4.2)

bundle show

 bundle show 
Gems included by the bundle:
  * bundler (1.13.7)
  * capistrano (3.4.0)
  * capistrano-composer (0.0.6)
  * capistrano-file-permissions (1.0.0)
  * capistrano-symfony (1.0.0.rc1)
  * i18n (0.7.0)
  * net-scp (1.2.1)
  * net-ssh (3.0.2)
  * rake (10.4.2)
  * sshkit (1.8.1)

cap deploy

(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'deploy:updated'
/home/neil/development/blah/Capfile:2:in `<top (required)>'
LoadError: cannot load such file -- capistrano/symfony
/home/neil/development/blah/Capfile:2:in `<top (required)>'
(See full trace by running task with --trace)

Any ideas?

set own environment variable for console commands

how can i do it?

I can see in debug log:

DEBUG[79c9a742] Command: cd /var/www/asdf/asdf/shared && ( SYMFONY_ENV=prod /usr/bin/env [ -e composer.phar ] )

how can i add another param to that SYMFONY_ENV?

Tasks don't run

This issue has been already tackled within other tickets but I still have them.

In my deploy.rb explicitly calling after 'deploy:updated', 'symfony:assetic:dump' doesn't have an effect. The same goes for any other task, e.g. before 'deploy:updated', 'bower:install'.

Deploying Symfony in dev environment

I have a staging server that I use to test my application. The issue is if I try setting :symfony_env, "dev" I get the following error during the composer install phase.

[RuntimeException]                                                           
  An error occurred when executing the "'cache:clear --no-warmup'" command:    
  PHP Fatal error:  Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in ../../AppKernel.php on line 40                                                            

This makes sense, but I don't see in the docs where to override the default composer install --no-dev --prefer-dist --no-interaction --quiet ...

Cannot load such file -- capistrano/symfony

Hey guys,

First, apologies if this problem is not related to this repository,
This is my very first time with capistrano and ruby in general.

When I try to launch any capistrano command such as cap deploy:setup, it fails with the following error:

(Backtrace restricted to imported tasks)
cap aborted!
LoadError: cannot load such file -- capistrano/symfony

I am using OS X 10.10.3

ruby -v: ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
gem -v: 2.0.14

Here is my local configuration (root is my application project folder):

Gemfile:

source "https://rubygems.org"

# Capistrano/symfony
gem 'capistrano', '~> 3.1'
gem 'capistrano-symfony', '~> 0.1', :github => 'capistrano/symfony'

Capfile:

require 'capistrano/symfony'

load 'my-deploy-configuration-file.rb'

I've also run bundle install.
When I run bundle show, I've got the following:

Gems included by the bundle:
  * bundler (1.10.5)
  * capistrano (3.4.0)
  * capistrano-composer (0.0.6)
  * capistrano-file-permissions (0.1.1)
  * capistrano-symfony (0.4.0 f557b3c)
  * colorize (0.7.7)
  * i18n (0.7.0)
  * net-scp (1.2.1)
  * net-ssh (2.9.2)
  * rake (10.4.2)
  * sshkit (1.7.1)

I've also tried replacing capistrano/symfony by capistrano-symfony in my Capfile, but the error is the same (Cannot load such file -- capistrano-symfony)

Did I miss a step?

Doctrine integration

I haven't found any previous discussions about this topic, so I start one here:

One thing that is missing from this gem (and we had it in capifony) is doctrine integration.

I have this basic list of doctrine tasks:

namespace :doctrine do
    namespace :schema do
        desc "Drop doctrine schema"
        task :drop do
            on roles(:app) do
                invoke "symfony:console", "doctrine:schema:drop", "--force"
            end
        end

        desc "Create doctrine schema"
        task :create do
            on roles(:app) do
                invoke "symfony:console", "doctrine:schema:create"
            end
        end
    end

    namespace :migrations do
        desc "Execute doctrine migrations"
        task :migrate do
            on roles(:app) do
                invoke "symfony:console", "doctrine:migrations:migrate", "--no-interaction"
            end
        end
    end

    namespace :fixtures do
        desc "Load doctrine fixtures"
        task :load do
            on roles(:app) do
                invoke "symfony:console", "doctrine:fixtures:load", "--no-interaction"
            end
        end
    end
end

I am aware of https://github.com/glooby/capistrano-symfony-doctrine, but I think it would be better to have it in the symfony package. Also, I propose the following improvements:

  • Support different entity managers
  • Roles and environment should be defined by the user when using the specific tasks in the configuration

What do you think?

Gem naming conflict

Hi there,

I'm posting here to talk about this issue.

In fact, we think this is a good solution to leave the capistrano-symfony and allow you to use it.

Our capistrano module can handle parameters.yml uploads when this is needed. And I'll be really happy to see this feature implemented in the capistrano/symfony module.

Regards,
Thomas.

Error: no implicit conversion of nil into String

I'm having an issue using the default values for some of the available options in this plugin. If I just add "require 'capistrano/symfony'" to my deploy.rb, I get an error about symfony_cache_path being null. I played around with this locally to see if I could figure out what was happening, it seems like either defaults.rb or paths.rb isn't really running or is running in the wrong order, but I'm not familiar with ruby/capistrano enough to really know how it's supposed to happen.

Note, this is an old project that I was in the process of converting over from capifony to capistrano 3 and it is stuck on symfony 2.2.1 for now. Not sure if that would cause this issue though.

Workaround
This is a totally valid workaround, so I'm not really concerned about this bug getting resolved, I just wanted to note it in case anyone else ran into this issue.

It works fine if you just set the cache_path in deploy.rb. I get other errors but I didn't look into those as deeply. I really wanted to just use the defaults, but I wound up just copying the defaults from the readme and adding those to my project's deploy.rb.

set :app_path, "app"
set :cache_path, fetch(:app_path) + "/cache"


More things in case anyone wants to try to resolve this...
Stack Trace

** Invoke symfony:create_cache_dir (first_time)
** Execute symfony:create_cache_dir
DEBUG [eab82b51] Running /usr/bin/env if test ! -d /srv/oved/prps/releases/20151023124234; then echo "Directory does not exist '/srv/oved/prps/releases/20151023124234'" 1>&2; false; fi as [email protected]
DEBUG [eab82b51] Command: if test ! -d /srv/oved/prps/releases/20151023124234; then echo "Directory does not exist '/srv/oved/prps/releases/20151023124234'" 1>&2; false; fi
DEBUG [eab82b51] Finished in 0.086 seconds with exit status 0 (successful).
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: no implicit conversion of nil into String
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
TypeError: no implicit conversion of nil into String
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/pathname.rb:392:in `initialize'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/pathname.rb:392:in `new'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/pathname.rb:392:in `join'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-symfony-0.4.0/lib/capistrano/symfony/dsl/paths.rb:20:in `symfony_cache_path'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-symfony-0.4.0/lib/capistrano/tasks/symfony.rake:59:in `block (4 levels) in <top (required)>'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:77:in `within'
/usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-symfony-0.4.0/lib/capistrano/tasks/symfony.rake:58:in `block (3 levels) in <top (required)>'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/usr/local/rvm/rubies/ruby-2.0.0-p643/lib/ruby/gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => symfony:create_cache_dir
The deploy has failed with an error: Exception while executing as [email protected]: no implicit conversion of nil into String

Some Other Info
I'm on a Vagrant instance running a precise32 box, here are some versions of things:

& ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [i686-linux]
& rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin [email protected], Michal Papis [email protected] [https://rvm.io/]
& gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
bundler-unload (1.0.2)
capifony (2.8.6)
capistrano (3.4.0, 2.15.6)
capistrano-composer (0.0.6)
capistrano-file-permissions (0.1.1)
capistrano-maintenance (0.0.3)
capistrano-symfony (0.4.0)
chunky_png (1.3.4)
colored (1.2)
colorize (0.7.7)
compass (1.0.3)
compass-core (1.0.3)
compass-import-once (1.0.5)
executable-hooks (1.3.2)
ffi (1.9.10)
gem-wrappers (1.2.7)
highline (1.7.8)
hipchat (1.5.2)
httparty (0.13.7)
i18n (0.7.0)
inifile (2.0.2)
io-console (0.4.2)
json (1.8.3, 1.7.7)
mimemagic (0.3.0)
minitest (4.3.2)
multi_json (1.11.2)
multi_xml (0.5.5)
net-scp (1.2.1)
net-sftp (2.1.2)
net-ssh (3.0.1)
net-ssh-gateway (1.2.0)
psych (2.0.0)
rainbow (2.0.0)
rake (10.4.2, 0.9.6)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
rdoc (4.0.0)
ruby-progressbar (1.4.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
sass (3.4.19)
scss_lint (0.42.2)
scss_lint_reporter_checkstyle (0.2.0)
sshkit (1.7.1)
terminal-notifier (1.6.3)
test-unit (2.0.0.0)

Task symfony:set_permissions invokes task deploy:set_permissions:* for each server in "release_roles :all"

Hi,

I'm working against capistrano 3.8 with capistrano-symfony 1.0.0.rc2 and I'm receiving the following error when deploying to an application with more than one host configured:

capistrano-symfony-invokes-task-multiple-times

Due to the nature of Rake each task can only be invoked once (unless manually reset with Rake::Task[...].reenable). Task symfony:set_permissions on line 61 of lib/capistrano/tasks/symfony.rake calls Capistrano DSL method invoke inside an on block:

task :set_permissions do
  on release_roles :all do
    if fetch(:permission_method) != false
      invoke "deploy:set_permissions:#{fetch(:permission_method).to_s}"
    end
  end
end

This means that if there are multiple hosts defined and release_roles :all returns more than one then the call to invoke happens more than once. Looking at the implementation of task deploy:set_permissions:acl for example, we see that it filters the hosts itself anyway:

task :acl => [:check] do
  ...
  on roles fetch(:file_permissions_roles) do |host|
    ...

... and therefore applying a filter in symfony:set_permissions won't do anything anyway. Proposed fix is to remove the filtering:

task :set_permissions do
  if fetch(:permission_method) != false
    invoke "deploy:set_permissions:#{fetch(:permission_method).to_s}"
  end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.