Git Product home page Git Product logo

composer'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.

composer's People

Contributors

armetiz avatar koenpunt avatar mremi avatar peterjmit avatar sam-realself avatar swalkinshaw avatar tkrajcar avatar will-in-wi 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

composer's Issues

Won't allow me to change values with ScriptHandler::buildParameters

Hi there,

I installed this plugin for my Symfony2 project. When the composer install task runs, it doesn't ask me to provide parameters like it does if I run composer install manually. I have this in my composer.json file:

"scripts": {
     "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        ]
    },
    "extra": {
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
    },

If it doesn't generate correct parameter file, the next hook clearCache won't work properly because of the wrong database connection. Is there anything I can do to get buildParameters working during a deployment?

I do not have --no-interaction argument in the composer install command.

PHP Variable not changing

During the deploy capistrano try to download composer with "php" but it should use "php7cli".
I've added these lines in my deploy.rb:
SSHKit.config.command_map[:php] = "php7cli" SSHKit.config.command_map[:composer] = "php7cli #{shared_path.join("composer.phar")}"

php7cli is and alias in my .bashrc. I've tried it with an complete path but still it doesnt work.

I've also tried this in my production.rb:
etch(:default_env).merge!(PATH: '$PATH:usr/local/bin/php7-70STABLE-CLI')

Still... No luck for me

Wrong usage of application symbol

Originally came from xuwupeng2000/capistrano-scm-gitcopy#33.

I'm not sure if this is NOT a Capistrano issue. But since everything used to work fine in staging before implementing scm-gitcopy into production I will post it here.

In my deploy.rb my application symbol is set to:

set :application, 'Semcoglas'
set :deploy_to, '/var/www/semcoweb'

I always regarded application as App name.

When I run cap production deploy everything works fine so far. All paths are used correctly based on the deploy_to symbol.

But then, when Composer is supposed to run, the path suddenly changes to /var/www/Semcoglas <- name of the :application symbol.

Of course I get a _Could not open file: /var/www/Semcoglas/shared/composer.phar_ error.

I tried without defining :application and indeed the wrong path will become /var/www/shared/....

Any idea what is happening here?

Add a command to clear-cache

We have had an issue with the composer cache contained the incorrect version of a dependency and needed to clear the composer cache.

It would be useful to have such a command that can use use temporarily to fix this.

Run multiple time the hook

Hello there,

I hope the project is not as abandoned as it looks like.
I have a project with multiple subproject (two in this case) and I want to run composer install inside this two directories. Is there a way to do so ? I can't find a solution for now. I can run composer install in one of the two directory but not in the second. Event if I create another custom task wich reset composer_ variables then invoke composer:run, :install (I think the implementation is good, see below)
Thanks.

Here is a representation of my architecture:

my_root_project
|__ symfony_projecet_1 # I want to run composer install here
|   |__ composer.lock
|   |__ composer.json
|__ symfony_project_2 # I want to run composer install here too
    |__ composer.lock
    |__ composer.json

Implementation of my custom_task:

namespace :portal do

  task :composer do
    on roles fetch(:composer_roles) do
      # Before this set, composer_working_dir is defined like this in the global configuration:
      # set :composer_working_dir, -> { File.join(fetch(:release_path), 'server') }
      set :composer_working_dir, -> { File.join(fetch(:release_path), 'portal') }
      within fetch(:composer_target_path, release_path) do
        invoke 'composer:run', :install, fetch(:composer_install_flags)
      end
    end
  end
end

Error when `set :composer_roles, :all` not in `deploy.rb`

When I don't set set :composer_roles, :all in my config.rb file I get the following error when running a command with a composer task (bundle exec cap production composer:install):

cap aborted!
NoMethodError: undefined method `to_sym' for nil:NilClass
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:25:in `each'
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:25:in `flat_map'
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:25:in `required'
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:15:in `roles'
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:11:in `for'
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers.rb:45:in `fetch_roles'
/home/leon/.dotfiles/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.0.1/lib/capistrano/configuration/servers.rb:18:in `roles_for'
Tasks: TOP => composer:run
(See full trace by running task with --trace)

Example of overriding configuration?

I don't have permission to install /usr/local/bin/composer on my remote server, so I've tried overriding the composer_path unsuccessfully.

I've tried set :composer_path, "./composer.phar" before and after require 'capistrano/composer' in my Capfile and config/deploy.rb

If you can provide any guidance, it would be greatly appreciated.

PHP binary with arguments

On the Task composer:install_executable which executes

task :install_executable do
    on release_roles(fetch(:composer_roles)) do
      within shared_path do
        unless test "[", "-e", "composer.phar", "]"
          composer_version = fetch(:composer_version, nil)
          composer_version_option = composer_version ? "-- --version=#{composer_version}" : ""
          execute :curl, "-s", fetch(:composer_download_url), "|", :php, composer_version_option
        end
      end
    end
  end

I need to change the php binary including its arguments.

The default commend which is being executed looks like this:
curl -s https://getcomposer.org/installer | php

What I need is:
curl -s https://getcomposer.org/installer | php56 -d allow_url_fopen=On

What I already know does not work:

  • Can't use the command_map because only the first argument of a execute statement gets resolved with the command_map
  • Can't use the workaround with fetch(:default_env).merge!(PATH: '$PATH:/usr/bin/php56 -d allow_url_fopen=On')

The only viable solution I see is the change the lib code :php to fetch(:php) (or similar) to be able to define the php binary (with its argument) with set :php, 'php -d allow_url_fopen=On'. Is this true or am I missing something?

composer_working_dir dependent on release path

If my composer project was in a subdirectory, I expect to be able to do

set :composer_working_dir, "directory/with/composer/project"

However this fails, since the default is dependent on :release_path. This dependency should probably be handled within the code. Or if I am misunderstanding the use of it, maybe a second variable for this would be useful.

Never having used ruby before, I came up with this alternative:

set :composer_working_dir, Proc.new { fetch(:release_path) ? fetch(:release_path) + "mySubdirectory" :"" }

Might be related to this: #36

Command mapping

Hey there, thanks for creating this gem 🙇

I've run into an issue when following the instructions in the README as the shared_path is not necessarily set correctly when you define the command mapping in the top-level scope.

Instead, what worked for me was to defer the mapping until after deploy:starting, where we can be sure the shared_path is initialized to the correct value:

namespace :deploy do
  # Add command mappings
  after :starting, :map_commands do
    SSHKit.config.command_map[:composer] = "php #{shared_path.join('composer.phar')}"
  end

  # Install composer (https://getcomposer.org/)
  after :starting, 'composer:install_executable'

  # …
end

Maybe it'd make sense to update the README and composer:install_executable task description?

Cachetool Capistrano plugin?

This is not directly related to the capistrano/composer plugin, but I didn't know where to best ask… Here seemed to be a somewhat suitable place since the target audience is likely similar.

Until recently I have never deployed a PHP project, so that was a bit of an adventure ⛵️🙂

However, I needed to clear the OPcache as part of the deployment and this seemed like it would be something that's a common task for PHP deployments. Hence I whipped up a cachetool.rake that obviously uses a lot of code I found here.

https://gist.github.com/pmeinhardt/0a9a72c2f9a07f51304bdb2ed581e52e

It is relatively small and has tasks that mirror all the cachetool commands:

cap cachetool:apc:bin:dump                # Get a binary dump of files and user variables
cap cachetool:apc:bin:load                # Load a binary dump into the APC file and user variables
cap cachetool:apc:cache:clear             # Clears APC cache (user, system or all)
cap cachetool:apc:cache:info              # Shows APC user & system cache information
cap cachetool:apc:cache:info:file         # Shows APC file cache information
cap cachetool:apc:key:delete              # Deletes an APC key
cap cachetool:apc:key:exists              # Checks if an APC key exists
cap cachetool:apc:key:fetch               # Shows the content of an APC key
cap cachetool:apc:key:store               # Store an APC key with given value
cap cachetool:apc:regexp:delete           # Deletes all APC key matching a regexp
cap cachetool:apc:sma:info                # Show APC shared memory allocation information
cap cachetool:apcu:cache:clear            # Clears APCu cache
cap cachetool:apcu:cache:info             # Shows APCu user & system cache information
cap cachetool:apcu:cache:info:keys        # Shows APCu keys cache information
cap cachetool:apcu:key:delete             # Deletes an APCu key
cap cachetool:apcu:key:exists             # Checks if an APCu key exists
cap cachetool:apcu:key:fetch              # Shows the content of an APCu key
cap cachetool:apcu:key:store              # Store an APCu key with given value
cap cachetool:apcu:regexp:delete          # Deletes all APCu key matching a regexp
cap cachetool:apcu:sma:info               # Show APCu shared memory allocation information
cap cachetool:help                        # Displays help for a command
cap cachetool:install_executable          # Installs cachetool.phar to the shared directory
cap cachetool:list                        # Lists commands
cap cachetool:opcache:configuration       # Get configuration information about the cache
cap cachetool:opcache:invalidate:scripts  # Remove scripts from the opcode cache
cap cachetool:opcache:reset               # Resets the contents of the opcode cache
cap cachetool:opcache:status              # Show summary information about the opcode cache
cap cachetool:opcache:status:scripts      # Show scripts in the opcode cache
cap cachetool:self-update                 # [selfupdate] Updates cachetool.phar to the latest version
cap cachetool:stat:clear                  # Clears the file status cache, including the realpath cache
cap cachetool:stat:realpath_get           # Show summary information of realpath cache entries
cap cachetool:stat:realpath_size          # Display size of realpath cache

I use it as follows:

# config/deploy.rb

# Set the cachetool default flags
#
# The deploy user is called `deploy-appname`,
# the socket file however is `appname-fpm.sock`.
set :cachetool_flags, %w[--fcgi="/var/run/php/${USER##deploy-}-fpm.sock"]

# Configure hooks
namespace :deploy do
  # Clear the PHP OPcache
  after :published, 'cachetool:opcache:reset'
end

Not sure whether this would be worth a separate Capistrano gem?

If so, I don't see myself maintaining it since the current PHP project is a bit of a rare bird among my projects so I wouldn't have much use for it.

However, if you're up for it, feel free to use the code from the Gist and do with it what you want 😉

Cheers 👋

Composer install stops deploy if there is no composer.json present in the release folder

I'm trying to use composer to install a plugin's dependencies, which are contained in a subfolder. I can set up my own task to cd to that directory and run composer install, but before I get to that point, the default install that runs when you require the gem tries to run composer install in the root release directory, and, when it can't find a composer.json file, exits with status 1 (with nothing written to stdout or stderr, due to the --quiet flag) and crashes the deploy.

Is there a way to prevent the default install from running?

When execute command cap staging deploy

When i run cap staging deploy
i got Errorr

DEBUG [5050e3d8] PHP Warning: require(/home/tricktionary/public_html/releases/20211210131149/vendor/composer/../symfony/polyfill-php81/bootstrap.php): failed to open stream: No such file or directory in /home/tricktionary/public_html/releases/20211210131149/vendor/composer/autoload_real.php on line 75

PHP Fatal error: require(): Failed opening required '/home/tricktionary/public_html/releases/20211210131149/vendor/composer/../symfony/polyfill-php81/bootstrap.php' (include_path='/home/tricktionary/public_html/releases/20211210131149/vendor/magento/zendframework1/library:.:/usr/share/php') in /home/tricktionary/public_html/releases/20211210131149/vendor/composer/autoload_real.php on line

composer exit status: 2

I get an error while running capistrano deploy: composer exit status: 2

Here is the full error output:

** Invoke deploy:updated (first_time)
** Invoke composer:install (first_time)
** Execute composer:install
** Invoke composer:run (first_time)
** Execute composer:run
INFO[28cd8f39] Running /usr/bin/env composer install --no-dev --no-interaction --verbose --optimize-autoloader on dev2.dlabs.si
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host dev2.dlabs.si: composer exit status: 2
composer stdout: Nothing written
composer stderr: Nothing written
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/var/lib/gems/1.9.1/gems/capistrano-composer-0.0.4/lib/capistrano/tasks/composer.rake:27:in `block (4 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in `within'
/var/lib/gems/1.9.1/gems/capistrano-composer-0.0.4/lib/capistrano/tasks/composer.rake:26:in `block (3 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SSHKit::Command::Failed: composer exit status: 2
composer stdout: Nothing written
composer stderr: Nothing written
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/var/lib/gems/1.9.1/gems/capistrano-composer-0.0.4/lib/capistrano/tasks/composer.rake:27:in `block (4 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in `within'
/var/lib/gems/1.9.1/gems/capistrano-composer-0.0.4/lib/capistrano/tasks/composer.rake:26:in `block (3 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => composer:run
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing on host dev2.dlabs.si: composer exit status: 2
composer stdout: Nothing written
composer stderr: Nothing written
>
** Invoke deploy:failed (first_time)
** Execute deploy:failed

Fetch :deploy_to from stage file

In my deploy.rb I have set :deploy_to, '/var/www/my_app' but in my production.rb I have to have set :deploy_to, '/home/http/my_app/deploy'. Composer is downloaded and installed into /home/http/my_app/deploy/shared/ but when Capistrano tries to run it to install the vendor dir it fails because it looks for /var/www/my_app.

The only way to get around this is to move the correct set :deploy_to directly in the deploy.rb file. But now I have to change it manually each time I deploy to staging or dev.

Not sure if I have done something wrong though. :) I'm still quite new to Capistrano and my only Ruby knowledge is from Capistrano.

These are my composer settings in deploy.rb:

set :composer_install_flags, "--no-dev --no-interaction --optimize-autoloader --prefer-dist"
set :composer_roles, :all
set :composer_dump_autoload_flags, '--optimize'
set :composer_download_url, "https://getcomposer.org/installer"

SSHKit.config.command_map[:composer] = "#{shared_path.join("composer.phar")}"

Option for Composer working dir

There's currently no way to specify a different path than release_path for Composer to run in. Either need to add an option for that or use Composer's working_dir.

cap "environment" deploy:check should fail if no composer is found

Hello!

I'm taking a long shot here, as I don't really know how/if this is possible, but I think that deploy:check task should check if there is a composer binary on the server and if it is usable (something like running a composer -v maybe?). Right now, deploy:check just passes, but the actual deploy fail when no composer is found on the server to install packages. What do you think?

Ability to copy vendor-folder from a previous release

Very often between two deployments only a few, or even no package changed. This means, that the whole vendor/-folder remains exactly the same, or only some packages need upates. Copying the vendor/-folder from a previous commit prevents you from installing every package during every deployment, but only the packages, that actually changed.

Some notes:

  • If the bin-dir-setting in the composer.json points to a folder outside the vendor/-folder (default ./vendor/bin), the symlinks created there are lost, when the corresponding package isn't (re-)installed
  • When there are changes within vendor/-folder (for whatever reason) they are copied too. So it is only useful in environment, that are completely under your control

Override PHP Path

I am trying to run the composer:install_executable task, however the path to php is incorrect as it is in a custom on my server and does not respond to just php for multiple version installs. is there a way to override :php in deploy.rb or deploy/environment.rb?

I've tried neither work:

SSHKit.config.command_map[:php] = '/path/to/php/bin/php'
set :php, '/path/to/php/bin/php'

Line 17 composer.rake

execute :curl, "-s", fetch(:composer_download_url), "|", :php, composer_version_option

Should :php possibly be fetch(:php) much like the :composer_download_url?

Or am I just doing it wrong?

Share composer path between stages

Hi,

What's the best way to share composer path between stages? I mean the following config requires the deploy_to variable which is probably specific to the stage:

SSHKit.config.command_map[:composer] = "#{shared_path.join("composer.phar")}"

So must be in each config/deploy/#{stage}.rb and cannot shared in config/deploy.rb.

Or maybe I missed something?

Thanks

Provide Option for PHP version with composer:install_executable

Not all systems have a binary on the path for php. Systems with multiple PHP versions installed generally append the version number to the end. For example:

which php72
/usr/bin/php72

which php56
/usr/bin/php56

To work around this an option that allows the PHP version to be specified works. This could be along the lines of:

set :composer_php_version, :php72

or

set :composer_php_version, '/usr/bin/php72'

The default version would always be :php

Related issues:

  • #46 - This one tries to use php56 (but with args).

Composer:install should accept an optional directory/path argument

In my use case, I have a submodule that manages its dependencies with
composer. Currently, composer:install is hard-coded to run within
release_path, which fails, with no option to change directories, as
composer cannot find a suitable composer.json. Allowing the user to
specify an execution path for the install command would be most helpful!

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.