Search code examples
phpsymfonydeploymentcapifony

Symfony2 + Capifony - Crash during deploying


I don't know what I do with that. I am trying to deploy Symfony 2 application 3 days. I also tried to use DeployBundle, but it didn't work cause windows and rsync problems. Now I am trying to use capifony again. The Capifony has tragic documentation...

I gave up connecting to bitbucket repository, because I had problems with ssh keys. Now I use locally repository, but server is remote and I am connected via openVPN. If I will use cap deploy or cap deploy:cold (I don't know what there is a difference), so capifony didn't say exactly what is the problem. I also found that it is possible to deploy into local folder Deploy application to localhost using Capistrano.

But capifony says the task local does not exist. I don't know how to the developer was able to use this command.

My capifony log (during deploy to server):

JoHn@JOHN-PC /d/Prace/Project/web/os-project/web (master)
$ git branch -D deploy
Deleted branch deploy (was 5f8a385).

JoHn@JOHN-PC /d/Prace/Project/web/os-project/web (master)
$ cap deploy:cold
DL is deprecated, please use Fiddle
  * 2015-01-19 22:33:33 executing `deploy:cold'
  * 2015-01-19 22:33:33 executing `deploy:update'
 ** transaction: start
  * 2015-01-19 22:33:33 executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
--> Updating code base with copy strategy
    executing locally: "git ls-remote d:\\Prace\\Project\\web\\os-project\\ ma
ster"
    command finished in 90ms
  * getting (via checkout) revision 5f8a385ac83bf26188b3ab58ce985a3b45dfc96f to
C:/Users/JoHn/AppData/Local/Temp/20150119213334
    executing locally: git clone -q -b master d:\Prace\Project\web\os-project\
 C:/Users/JoHn/AppData/Local/Temp/20150119213334 && cd C:/Users/JoHn/AppData/Loc
al/Temp/20150119213334 && git checkout -q -b deploy 5f8a385ac83bf26188b3ab58ce98
5a3b45dfc96f
    command finished in 2694ms
  * Compressing C:/Users/JoHn/AppData/Local/Temp/20150119213334 to C:/Users/JoHn
/AppData/Local/Temp/20150119213334.tar.gz
    executing locally: tar czf 20150119213334.tar.gz 20150119213334
    command finished in 2761ms
    servers: ["10.0.0.61"]
[email protected]'s password:
 ** sftp upload C:/Users/JoHn/AppData/Local/Temp/20150119213334.tar.gz -> /tmp/2
0150119213334.tar.gz
    [10.0.0.61] /tmp/20150119213334.tar.gz
    [10.0.0.61] done
  * sftp upload complete
  * executing "cd /var/www/html/project/releases && tar xzf /tmp/20150119213334
.tar.gz && rm /tmp/20150119213334.tar.gz"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 491ms
  * 2015-01-19 22:34:33 executing `deploy:finalize_update'
  * executing "chmod -R g+w /var/www/html/project/releases/20150119213334"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 264ms
--> Creating cache directory
  * executing "sh -c 'if [ -d /var/www/html/project/releases/20150119213334/app
/cache ] ; then rm -rf /var/www/html/project/releases/20150119213334/app/cache;
 fi'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 260ms
  * executing "sh -c 'mkdir -p /var/www/html/project/releases/20150119213334/ap
p/cache && chmod -R 0777 /var/www/html/project/releases/20150119213334/app/cach
e'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 94ms
  * executing "chmod -R g+w /var/www/html/project/releases/20150119213334/app/c
ache"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 153ms
  * 2015-01-19 22:34:34 executing `deploy:share_childs'
--> Creating symlinks for shared directories
  * executing "mkdir -p /var/www/html/project/shared/app/logs"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 292ms
  * executing "sh -c 'if [ -d /var/www/html/project/releases/20150119213334/app
/logs ] ; then rm -rf /var/www/html/project/releases/20150119213334/app/logs; f
i'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 320ms
  * executing "ln -nfs /var/www/html/project/shared/app/logs /var/www/html/anim
alco/releases/20150119213334/app/logs"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 292ms
  * executing "mkdir -p /var/www/html/project/shared/web/uploads"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 160ms
  * executing "sh -c 'if [ -d /var/www/html/project/releases/20150119213334/web
/uploads ] ; then rm -rf /var/www/html/project/releases/20150119213334/web/uplo
ads; fi'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 210ms
  * executing "ln -nfs /var/www/html/project/shared/web/uploads /var/www/html/a
nimalco/releases/20150119213334/web/uploads"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 310ms
--> Normalizing asset timestamps
  * executing "find /var/www/html/project/releases/20150119213334/web/css /var/
www/html/project/releases/20150119213334/web/images /var/www/html/project/rele
ases/20150119213334/web/js -exec touch -t 201501192134.36 {} ';' &> /dev/null ||
 true"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 303ms
    triggering after callbacks for `deploy:finalize_update'
  * 2015-01-19 22:34:36 executing `symfony:composer:install'
    triggering before callbacks for `symfony:composer:install'
  * 2015-01-19 22:34:36 executing `symfony:composer:get'
  * executing "if [ -e /var/www/html/project/releases/20150119213334/composer.p
har ]; then echo 'true'; fi"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 290ms
--> Downloading Composer
  * executing "sh -c 'cd /var/www/html/project/releases/20150119213334 && curl
-s http://getcomposer.org/installer | php'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
 ** [out :: 10.0.0.61] #!/usr/bin/env php
 ** [out :: 10.0.0.61] All settings correct for using Composer
 ** [out :: 10.0.0.61] Downloading...
 ** [out :: 10.0.0.61]
 ** [out :: 10.0.0.61] Composer successfully installed to: /var/www/html/animalc
o/releases/20150119213334/composer.phar
 ** [out :: 10.0.0.61]
 ** [out :: 10.0.0.61] Use it: php composer.phar
    command finished in 11613ms
--> Installing Composer dependencies
  * executing "sh -c 'cd /var/www/html/project/releases/20150119213334 && SYMFO
NY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --optimiz
e-autoloader --no-progress'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 314ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/html/project/releases/20150119213334; true"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 320ms
failed: "sh -c 'sh -c '\\''cd /var/www/html/project/releases/20150119213334 &&
SYMFONY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --op
timize-autoloader --no-progress'\\'''" on 10.0.0.61

I found many commands and their combinations, so my deploy.rb has many commented of commands for future using.

set :application, "project"
set :domain,      "10.0.0.61"
set :deploy_to,   "/var/www/html/project"
set :app_path,    "app"
set :user,        "kunesd"

#ssh_options[:forward_agent] = true
#ssh_options[:port] = "22"
set :branch, "master"

# set :symfony_env_prod, "dev"

set   :scm,           :git
set   :repository,    "d:\\Prace\\Project\\web\\os-project\\"
set   :deploy_via,    :copy
# 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, :primary => true       # This may be the same as your `Web` server

# Composer settings
# set :use_composer, true
#set :use_composer_tmp, true
# set :update_vendors, false
#set :vendors_mode, "install"

# General settings
#set :shared_files,    ["app/config/parameters.yml"]
#set :shared_children, [app_path + "/logs", web_path + "/uploads"]
set :keep_releases,  3
set :use_sudo, false
#set :writable_dirs,     [app_path + "/logs", app_path + "/cache", web_path + "/uploads"]
#set :webserver_user,    "www-data"
#set :permission_method, :acl
#set :use_set_permissions, true

# Be more verbose by uncommenting the following line
 logger.level = Logger::TRACE

Thank you for your answers.

#1 UPDATE

The error was in my folder structure:

  • .git
  • specification
  • images
  • web -> this is SF project, but Capifony required in set :repository .git folder in SF project.

Thanks @Matteo, it worked, but there is a new error:

  * Installing dependencies from lock file
  * Your requirements could not be resolved to an installable set of packages.
  * Problem 1
  * - Installation request for sensiolabs/security-checker v2.0.0 -> satisfiable
 by sensiolabs/security-checker[v2.0.0].
  * - sensiolabs/security-checker v2.0.0 requires ext-curl * -> the requested PH
P extension curl is missing from your system.
  * Problem 2
  * - sensiolabs/security-checker v2.0.0 requires ext-curl * -> the requested PH
P extension curl is missing from your system.
  * - sensio/distribution-bundle v3.0.8 requires sensiolabs/security-checker ~2.
0 -> satisfiable by sensiolabs/security-checker[v2.0.0].
  * - Installation request for sensio/distribution-bundle v3.0.8 -> satisfiable
by sensio/distribution-bundle[v3.0.8].

#2 UPDATE

My composer.json:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": {
            "": "src/",
            "SymfonyStandard": "app/"
        }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.5.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~3.0",
        "sensio/framework-extra-bundle": "~3.0",
        "incenteev/composer-parameter-handler": "~2.0",
        "components/jquery": "1.9.*",
        "oyejorge/less.php": "~1.5",
        "components/font-awesome": "4.2.0",
        "doctrine/doctrine-fixtures-bundle": "2.2.*",
        "symfony/serializer": "v2.5.7",
        "jms/serializer-bundle": "~0.13",
        "twbs/bootstrap": "3.3.*"
    },
    "require-dev": {
        "sensio/generator-bundle": "~2.3"
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.5-dev"
        }
    }
}

Solution

  • Debug your procedure deploy by launch the cap task as:

     cap -dv deploy
    

    and execute yourself on the server command line the problematic task (don't do that to capifony, take the task waiting meanwile, otherwise it will rollback the execution without prompt you the error)

    Then you can undestand the REAL problem.

    In details, The real problem is due on the missing php extension ext-curl on the shared server. Installing it the deploy works fine.

    Now the problem is about the web sever configuration on the correct web folder